asp.net 和 C# 的新手,任何帮助都会很棒谢谢。
我的代码
protected void Button1_Click(object sender, EventArgs e)
{
string x = "item_name1=number1&item_number1=product1";
NameValueCollection key = HttpUtility.ParseQueryString(x);
DataTable Theproducts = new DataTable();
Theproducts.Columns.Add("ProductID");
Theproducts.Columns.Add("ProductName");
DataRow row = Theproducts.NewRow();
int index = 1;
foreach(string keys in key.AllKeys)
{
if (keys == ("item_number" + index.ToString()))
{
row["ProductID"] = key[keys];
}
if (keys == ("item_name" + index.ToString()))
{
row["ProductName"] = key[keys];
}
Theproducts.Rows.InsertAt(row, 0);
}
GridView1.DataSource = Theproducts;
GridView1.DataBind();
}//end of button
收到错误此行已属于此表。