我用GridView做了一个绑定更新,如图:
可是调试的时候,却提示有:
代码如下:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string Id = GridView1.DataKeys[e.RowIndex].Value.ToString();
string EmId = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string EmName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
string EmAddress = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLAddress")).SelectedValue;
//string Email = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString();
string EmSex = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLSex")).SelectedValue;
DB.ExcuteSql("update Employe set EmpId=" + EmId + ",EmpName=" + EmName + ",EmpAddress=" + EmAddress + ",EmpSex=" + EmSex);
GridView1.EditIndex = -1;
Bind();
}
请各位帮我看看,在此谢过了
可是调试的时候,却提示有:
代码如下:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string Id = GridView1.DataKeys[e.RowIndex].Value.ToString();
string EmId = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string EmName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
string EmAddress = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLAddress")).SelectedValue;
//string Email = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString();
string EmSex = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLSex")).SelectedValue;
DB.ExcuteSql("update Employe set EmpId=" + EmId + ",EmpName=" + EmName + ",EmpAddress=" + EmAddress + ",EmpSex=" + EmSex);
GridView1.EditIndex = -1;
Bind();
}
请各位帮我看看,在此谢过了
指点一下方向
1. google一下:gridview 72般绝技
2. 学会用三层
3. 学会调试