首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

listbox数据始终显示在第一行,该如何处理

2012-04-25 
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方法
}
}
探讨

引用:
额 我想可能是因为你用的listBox的缘故 是不是初始没有选择的?因为我刚刚一直都是针对dropdownlist讲的 这个是初始必定有一个选中的~
你可以在if(!ispostback)里面在绑定1之后手动设置1的选项到第一个上面 这个顺序不能错 然后2也是这样~

引用:

引用:
有值 逻辑上 初次打开页面绑定的……

热点排行