如何使用数组绑定下拉列表 [英] How to Bind a dropdown using Array
本文介绍了如何使用数组绑定下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题.我想使用字符串数组绑定一个下拉列表.我正在使用从另一个页面调用的会话.会话现在工作正常,问题是当我绑定下拉列表时抛出错误..
I have a problem. I want to bind a dropdown using a string array. I am using a session which is called from another page. Session is working fine now the problem is when I bind the dropdown it throw an error..
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Name'
if (Session["Driver"] != null)
{
string[] arr_list = (string[])Session["Driver"];
DDDriver.DataSource = arr_list;
DDDriver.DataBind(); //<b>Error here.....</b>
DDDriver.Items.Add("select");
DDDriver.SelectedItem.Text = "select";
}
错误:System.String'' does not contain a property with the name ''Driver_Name''.
推荐答案
您正在将下拉菜单DataTextField的DataValueField的这些属性之一设置为"Driver_Name".删除此错误也应清除错误.
You are setting one of these properties on the drop down DataTextField, DataValueField to ''Driver_Name''. removing this should clear the error as well.
感谢Vivek ..它有效..Bingo Dude:)
Thanx Vivek..It Works..Bingo Dude :)
string[] a = new string[] {"Arun","vinay","Manju","Pavan" };
DropDownList1.DataSource = a.ToArray();
DropDownList1.DataBind();
检查一下
Check this out
这篇关于如何使用数组绑定下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文