how to scroll selected item in asp listbox in multiple mode?(如何在多种模式下滚动asp列表框中的选定项目?)
问题描述
我有一个选择模式为多个的列表框
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()
我将一个列表框 listbox1 项目发送到用户列表框,但按添加后我无法滚动到所选项目.
I am sending one listbox listbox1 item into userlistbox but after pressing add I can't get scrolled to selected item.
推荐答案
最好带html列表框
<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>--%>
在document.ready中使用jquery listbox change功能,我们可以在multiple模式下修改为
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); });
并在 .cs 代码后面编写以获取选定索引
and write behind .cs code to get slected index
这篇关于如何在多种模式下滚动asp列表框中的选定项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在多种模式下滚动asp列表框中的选定项目?
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
