listbox数据始终显示在第一行,该如何处理
listbox数据始终显示在第一行C# code前台 asp:ListBox IDListBox3 runatserver AutoPostBackTrue
listbox数据始终显示在第一行
C# code前台 <asp:ListBox ID="ListBox3" runat="server" AutoPostBack="True"onselectedindexchanged="ListBox3_SelectedIndexChanged1"> </asp:ListBox>后台 protected void ListBox3_SelectedIndexChanged1(object sender, EventArgs e) {string id1= this.ListBox1.SelectedItem.Value.ToString();string id2= this.ListBox2.SelectedItem.Value.ToString();string id3= this.ListBox3.SelectedItem.Value.ToString(); }
页面有3个listbox
点击listbox1中的数据 显示listbox2 点击listbox2中数据 显示listbox3
现在问题是
数据都能显示出来 但选中listbox3中某个数据时焦点老不在所选择的那个数据上 而是自动跳到第一个数据上
什么原因
[解决办法]抱歉把你搞晕了~我表达也有问题~
Page_Load
{
if(!ispostback)
{
绑定1方法;
ListBox1.SelectedIndex=1;
绑定2方法;
ListBox2.SelectedIndex=1;
绑定3方法
}
}