日期:2014-05-18  浏览次数:20501 次

关于一个得到用户控件中listbox值的简单问题,都来抢分吧
一个主页面Main.aspx包含一个用户控件UC1,用户控件里有一个ListBox
问题如下:
用this.Response.Write方法在页面显示出用户控件中ListBox的选中的Text值和SelectIndex值


------解决方案--------------------
ListItem lt = new ListItem(ListBox7.SelectedItem.Text, ListBox7.SelectedValue);
------解决方案--------------------
this.Response.Write(((ListBox)UC1.FindControl( "ListBox1 ")).Text);
this.Response.Write(((ListBox)UC1.FindControl( "ListBox1 ")).SelectIndex);
试一下呢。手写的
------解决方案--------------------
response.write(((ListBox)UC1.FindControl( "ListBox1 ")).SelectItem.Text);
response.write(((ListBox)UC1.FindControl( "ListBox1 ")).SelectItem.Value);