Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
        }

hi , i need an explanation for above code
I know that e.neweditindex enables me to make the selected row editable .
but my inquiry is that above code not working correctly until i write the below method
C#
GetDataFromCache();

which assign datasource to Grid and also bind it ,............... why i need to bind it again as it was already binded before.
Posted

This code helps you to get the respective row on which you clicked in the gridview & enables you to edit & update your content of that particular row in the gridview.
 
Share this answer
 
Comments
Hercal 25-Nov-14 9:19am    
thanks man , but my question was [why i should call the function every time] , any way thanks :)
whenever your page post back data is lost because http is Stateless protocol. To maintain data in grid either you call ur function every time or u can maintain data in Viewstate. if u r fetching data from backend in function and call that function everytimr it increase load on your server instead of that you should use viewstate


GridView1.EditIndex = e.NewEditIndex;
Datatable dt=ViewState["data"] as Datatable;
Gridview1.DataSource=dt;
GridView1.DataBind();
 
Share this answer
 
Comments
Hercal 25-Nov-14 9:18am    
thanks for your clarification :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900