hello sir,
how to edit gridview in asp.net
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandeep ShekhawatPosted Jun 8, 2011, 9:02 AM
Use
DataKeyNames="Emp_id" onrowcancelingedit="gridemp_RowCancelingEdit"
onrowdeleting="gridemp_RowDeleting" onrowediting="gridemp_RowEditing"
onrowupdating="gridemp_RowUpdating">
<%# Eval("Emp_Name") %>
<%# Eval("Emp_city") %>
aspx.cs page
protected void gridemp_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
i = Convert.ToInt32(gridemp.DataKeys[e.RowIndex].Value.ToString());
j = gen.UpdateEmp(i);
FillGrid();
}
protected void gridemp_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gridemp.EditIndex = -1;
FillGrid();
}
protected void gridemp_RowEditing(object sender, GridViewEditEventArgs e)
{
gridemp.EditIndex = e.NewEditIndex;
FillGrid();
}
protected void gridemp_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
i = Convert.ToInt32(gridemp.DataKeys[e.RowIndex].Value.ToString());
name = ((TextBox)gridemp.Rows[e.RowIndex].FindControl("txtname")).Text;
city= ((TextBox)gridemp.Rows[e.RowIndex].FindControl("txtcity")).Text;
gen.UpdateEmployee(i, name, city);
FillGrid();
}
vijayPosted Jun 8, 2011, 8:44 AM
http://vbdotnetaddict.blogspot.com/2011/02/groid-view-load-and-update-sql-data.html
Dorababu MekaPosted Jun 8, 2011, 6:19 AM
http://www.c-sharpcorner.com/UploadFile/sheesabidi/GridViewFunctionality02182009110634AM/GridViewFunctionality.aspx?ArticleID=49fb01e9-281d-4410-b995-309df285e902