DropDownList控件数据绑定

DropDownList控件的绑定Dictionary<int, string>
DropDownList控件的绑定DataTable
1、绑定Dictionary<int, string>
1Dictionary<intstring> temp = DBConfig.GetDataAdmin(fileName);
2this.ddlDicItem.DataSource = temp;
3this.ddlDicItem.DataTextField = "Value";
4this.ddlDicItem.DataValueField = "Key";
5this.ddlDicItem.DataBind();
2、绑定DataTable
1this.ddlAllDics.DataSource = DBConfig.Dictionary;
2this.ddlAllDics.DataTextField = DBConfig.Dictionary.Columns[1].ToString();
3this.ddlAllDics.DataValueField = DBConfig.Dictionary.Columns[0].ToString();
4this.ddlAllDics.DataBind();
特别是绑定Dictionary<int, string> ,开发中写成了
this.ddlDicItem.DataTextField = temp.Values.ToString();
这个怎么会不出错呢?失败...
posted on 2008-07-08 08:37  Xuemin_Zhang  阅读(342)  评论(0编辑  收藏  举报