I have a listbox with selection mode is multiple
<asp:ListBox id="Listbox1" runat="server" Width="230px" Height="168px" SelectionMode="Multiple"></asp:ListBox>
I am databinding using a datasource
Me.Listbox1.Items.Clear() Me.Listbox1.DataSource = ayl_arraylist_memberslist Me.Listbox1.DataTextField = "Key" Me.Listbox1.DataValueField = "Value" Me.Listbox1.DataBind()
I am sending one listbox listbox1 item into userlistbox but after pressing add I can’t get scrolled to selected item.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Better to take html list box
<select id="ListBox1" runat="server" size="10" style="width:230px; height:168px"></select> <%--<asp:ListBox id="ListBox1" runat="server" Width="230px" Height="174px" SelectionMode="Multiple" ></asp:ListBox>--%>
and using jquery listbox change function in document.ready we can modify at the multiple mode as
$("#ListBox1").attr("multiple", false);
$("#ListBox1").change(function () { $("#ListBox1").attr("multiple", true); });
and write behind .cs code to get slected index
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0