C# B/S程序中使用DropDownList出现System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中的解决方法
2008-10-14 23:28
1136 查看
在程序中使用DropDownList控件,向DropDownList中显示当前一个值,出现异常详细信息: System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。
究其原因,发现要显示的这个值在DropDownList控件已有的ITEM中没有这个值。
我在程序中这样处理的:
string strTemp="aaa";
ListItem item = DropDownList1.Items.FindByValue(strTemp);
if (item != null)
{
DropDownList1.Text = strTemp;
}
strTemp是要显示的字符串。
究其原因,发现要显示的这个值在DropDownList控件已有的ITEM中没有这个值。
我在程序中这样处理的:
string strTemp="aaa";
ListItem item = DropDownList1.Items.FindByValue(strTemp);
if (item != null)
{
DropDownList1.Text = strTemp;
}
strTemp是要显示的字符串。
相关文章推荐
- System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中
- 解决DropDownList 有一个无效 SelectedValue,因为它不在项目列表中。这是怎么回事?
- 错误:dropdownlist有一个无效 SelectedValue,因为它不在项目列表中。
- “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。
- “DropDownList2”有一个无效 SelectedValue,因为它不在项目列表中 问题的解决
- 解决 有一个无效 SelectedValue,因为它不在项目列表中
- 解决 有一个无效 SelectedValue,因为它不在项目列表中
- 解决 有一个无效 SelectedValue,因为它不在项目列表中
- 解决 有一个无效 SelectedValue,因为它不在项目列表中
- 解决错误 “DropDownList1”有一个无效 SelectedIndex,因为它不在项目列表中。
- AsParallel \AsQueryable<T>().ToList() [System.ArgumentOutOfRangeException was unhandled" 索引超出范围。必须为非负值并小于集合大小]解决方法
- ASP.NET中的DropDownList控件出错"DropDownList有一个无效 SelectedValue,因为它不在项目列表中。"
- "DropDownList1“有一个无效 SelectedValue,因为它不在项目列表中。
- ASP.net 异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。解决方法
- Gradle 使用Jetty插件启动web项目时出现"java.lang.OutOfMemoryError: PermGen space"解决方法
- 有一个无效 SelectedValue,因为它不在项目列表中
- 巧解 有一个无效 SelectedValue,因为它不在项目列表中。异常
- DataGridView绑定Ilist对象,出现IndexOutOfRangeException错误的解决方法
- 有一个无效 SelectedValue,因为它不在项目列表中。
- 有一个无效 SelectedValue,因为它不在项目列表中