怎样把数组添加到DataTable,并绑到DropDownList? string s1 = "第一项|第二项|第三项";string s2 = "value1|value2|value3";var ar1 = s1.split('|');var ar2 = s2.split('|');如何将 a1和a2添加到DataTable中的DEMO表中呢?并将数据绑到DropDownList? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如何将 ar1和ar2添加到DataTable中的DEMO表中呢?并将数据绑到DropDownList? string s1 = "第一项|第二项|第三项";string s2 = "value1|value2|value3";stringp[] ar1 = s1.split('|');string [] ar2 = s2.split('|'); DataTable table = new DataTable(); for (int i = 0; i <ar1.Count; i++) {NewRow = table.NewRow(); NewRow["t"] =ar1[i].ToString(); NewRow["v"] =ar1[i].ToString(); table.Rows.Add(NewRow); } this.DropDownList4.DataSource = table; this.DropDownList1.DataValueField = "v"; this.DropDownList1.DataTextField = "t"; this.DropDownList1.DataBind(); 谢谢了大哥您打快了,我发个测试通过的 string s1 = "第一项|第二项|第三项"; string s2 = "value1|value2|value3"; var ar1 = s1.Split('|'); var ar2 = s2.Split('|'); DataTable table = new DataTable(); table.Columns.Add("t"); table.Columns.Add("v"); for (int i = 0; i < ar1.Length; i++) { DataRow NewRow = table.NewRow(); NewRow["t"] = ar1[i].ToString(); NewRow["v"] = ar1[i].ToString(); table.Rows.Add(NewRow); } this.DropDownList1.DataSource = table; this.DropDownList1.DataValueField = "v"; this.DropDownList1.DataTextField = "t"; this.DropDownList1.DataBind();结贴了 ProwerShell 查询excel的sql语句无法排序的问题 求asp.netQQ视频聊天及语音聊天代码及群聊,私聊代码(在线等) 怎么为用户控件中的控件赋值?【有代码】 关于对html操作 EXTJS YuiGrid控件 在母版页下面使用 事件无效 一个用WebEasyMail架构Web邮件服务器 有兴趣的帮我看一下代码 ListVew绑定Linq匿名类型查询结果,结合DataPager分页后的错误:ListView 具有的数据源必须实现 ICollection aspx里面加一段代码 简单问题,随便散分 .NET 和 J2EE目前 哪个就业形势好啊
string s2 = "value1|value2|value3";
stringp[] ar1 = s1.split('|');
string [] ar2 = s2.split('|');
DataTable table = new DataTable();
for (int i = 0; i <ar1.Count; i++)
{
NewRow = table.NewRow();
NewRow["t"] =ar1[i].ToString();
NewRow["v"] =ar1[i].ToString();
table.Rows.Add(NewRow);
}
this.DropDownList4.DataSource = table;
this.DropDownList1.DataValueField = "v";
this.DropDownList1.DataTextField = "t";
this.DropDownList1.DataBind();
string s1 = "第一项|第二项|第三项";
string s2 = "value1|value2|value3";
var ar1 = s1.Split('|');
var ar2 = s2.Split('|');
DataTable table = new DataTable();
table.Columns.Add("t");
table.Columns.Add("v");
for (int i = 0; i < ar1.Length; i++)
{
DataRow NewRow = table.NewRow();
NewRow["t"] = ar1[i].ToString();
NewRow["v"] = ar1[i].ToString();
table.Rows.Add(NewRow);
}
this.DropDownList1.DataSource = table;
this.DropDownList1.DataValueField = "v";
this.DropDownList1.DataTextField = "t";
this.DropDownList1.DataBind();结贴了