how to scroll selected item in asp listbox in multiple mode?

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:31:36

问题


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.


回答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



来源:https://stackoverflow.com/questions/11840034/how-to-scroll-selected-item-in-asp-listbox-in-multiple-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!