如何获取动态添加的listBox的值 asp.net c#
Page_Load函数中写入ListBoxneedList=newListBox();needList.ID="needListBox";SqlDataSourcenee...
Page_Load函数中写入
ListBox needList = new ListBox();
needList.ID = "needListBox";
SqlDataSource needListSql = new SqlDataSource();
needListSql.ID = "needListSqlDataSource";
needListSql.ConnectionString = ConfigurationSettings.AppSettingS["oneConnectionString"];
needListSql.SelectCommand = "SELECT [need] FROM [needTable] ORDER BY [ID]";
rightTwo.Controls.Add(needListSql);
needList.DataTextField = "need";
needList.DataSourceID = "needListSqlDataSource";
needList.DataValueField = "need";
needList.SelectedIndexChanged += needList_SelectedIndexChanged;
rightTwo.Controls.Add(needList);
在needList_SelectedIndexChanged函数中如何获取listBox选择的值
1楼 因为是后台添加的listBox控件,直接用控件名称或ID都无法索引到listBox,提示--当前上下文不存在名称needList page_load函数中的rightTwo是一个Div标签 展开
ListBox needList = new ListBox();
needList.ID = "needListBox";
SqlDataSource needListSql = new SqlDataSource();
needListSql.ID = "needListSqlDataSource";
needListSql.ConnectionString = ConfigurationSettings.AppSettingS["oneConnectionString"];
needListSql.SelectCommand = "SELECT [need] FROM [needTable] ORDER BY [ID]";
rightTwo.Controls.Add(needListSql);
needList.DataTextField = "need";
needList.DataSourceID = "needListSqlDataSource";
needList.DataValueField = "need";
needList.SelectedIndexChanged += needList_SelectedIndexChanged;
rightTwo.Controls.Add(needList);
在needList_SelectedIndexChanged函数中如何获取listBox选择的值
1楼 因为是后台添加的listBox控件,直接用控件名称或ID都无法索引到listBox,提示--当前上下文不存在名称needList page_load函数中的rightTwo是一个Div标签 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询