Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code for gridview update event.after i change value in text box in edit mode still it passes old value..


protected void SubCategoryGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
       {
           string scn;
           int catid;
           int scatid = Convert.ToInt32(((Label)(SubCategoryGrid.Rows[e.RowIndex].FindControl("scidlbl"))).Text);
           TextBox box1 = (TextBox)SubCategoryGrid.Rows[e.RowIndex].FindControl("txteditscatname");
           TextBox txt2 = (TextBox)SubCategoryGrid.Rows[e.RowIndex].FindControl("txteditcatid");

           scn = box1.Text;
           catid = Convert.ToInt32(txt2.Text);
           d.editsubcategory(scn, scatid,catid);
           SubCategoryGrid.EditIndex = -1;
           FILLSUBCATGRID();
       }
Posted
Updated 1-Feb-13 21:18pm
v4
Comments
Taha Akhtar 2-Feb-13 5:16am    
make sure your in page load of !isPostback check
rrjoshi2321992 2-Feb-13 14:26pm    
thanx..

1 solution

after i change value in text box in edit mode still it passes old value..
This generally happens when you rebind the grid again before the event is raised. To handle/avoid it, make sure you have wrapped your datagrid databind code within page property IsPostback.
C#
if(!IsPostback)
{
  // gridview1.Datasource
  // gridview.Databind()
}
 
Share this answer
 
Comments
rrjoshi2321992 2-Feb-13 14:25pm    
thanx. worked 4 me.
Sandeep Mewara 2-Feb-13 14:36pm    
Welcome.

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