报错:行 107: {
行 108: //取得表的主键
行 109: string a = this.GridView1.DataKeys[e.RowIndex].Values[0].ToString();
行 110:
行 111: //取得对应的字符串
我的代码如下:
string a = this.GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string b = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString();
string c = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString();
public string b = "学校名称";
public string c = "学校地址";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string a = GridView1.DataKeys[i].Value.ToString()
}
if (e.Row.RowType != RowType.Header )
if (e.CommandName == "aaa")
{
string a = this.GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string b = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString();
string c = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString();
}看这样行不行
问题已经解决了`
只要在GridView列表属性的DataKeyNames项里添加所设为主键的字段名就可以`