How to update GridView data by passing them into textBoxes outside gridview in asp.net?.
My intention is when I lick edit button in gridview, which is linkbutton, I need the concerned data to passes into the Class Name and NoOfSeats TextBox outside GridView. How can it done?
Here is my application:-
Here my GridView_RowUpdating Event:-
protected void gvClass_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
classSP spClass = new classSP();
classInfo infoClass = new classInfo();
GridViewRow gvRow = gvClass.Rows[e.RowIndex];
infoClass.classId = decimal.Parse(gvClass.DataKeys[e.RowIndex].Value.ToString());
infoClass.className = ((TextBox)gvRow.FindControl("txtClassName")).Text;
infoClass.noOfSeats = int.Parse(((TextBox)gvRow.FindControl("txtNoOfSeats")).Text);
int inCount = spClass.ClassEdit(infoClass);
gvClass.EditIndex = -1;
GridFill();
}
catch (Exception)
{
throw;
}
}

Dhirendra MisraPosted Dec 30, 2013, 3:14 AM
You want that if any row you select, that values should be visible at textboxes and change values there and then update. It is better to use a link button within grid rather than using <EditItemTemplate>. Make use of DataKeyNames attribute of grid, OnRowCommand event to pick values of row from cells and assign it to relevant textboxes.
Use save button to update and refresh the grid.
Don't go for
Onrowcancelingedit
Onrowediting
Onrowupdating
Onrowcancelingedit