It appears that the values are empty, but I acnnot figure out why. Thanks for replying.
Get the values from the controls in the GridView then:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
int id = Convert.ToInt32(row.Cells[0].Text); // if id is a readonly field in your GridView
string name = ((TextBox)(row.Cells[1].Controls[0])).Text;
string desc = ((TextBox)(row.Cells[2].Controls[0])).Text;
productTableAdapter pAdapter = new productTableAdapter();
pAdapter.Update(id, name, description);
GridView1.EditIndex = -1;
GridView1.DataBind();
}
mm10
Contributor
6455 Points
1187 Posts
Re: TableAdapter Update GridView
Apr 11, 2012 07:19 AM|LINK
Get the values from the controls in the GridView then:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; int id = Convert.ToInt32(row.Cells[0].Text); // if id is a readonly field in your GridView string name = ((TextBox)(row.Cells[1].Controls[0])).Text; string desc = ((TextBox)(row.Cells[2].Controls[0])).Text; productTableAdapter pAdapter = new productTableAdapter(); pAdapter.Update(id, name, description); GridView1.EditIndex = -1; GridView1.DataBind(); }