asp.net - getting previous value before edition from textbox in gridview -


i applying edit functionality on gridview.

when code's control in rowupdating event, finding getting previous value textbox(i.e. value before make edit in textbox).

following code:

protected sub gvbooking_rowupdating(byval sender object, byval e system.web.ui.webcontrols.gridviewupdateeventargs) handles gvbooking.rowupdating             'dim name string = directcast(gvbooking.rows(e.rowindex).findcontrol("txtperson1"), textbox).text             dim nname string = (gvbooking.datakeys(e.rowindex).values("person_name").tostring)             dim id integer = integer.parse(gvbooking.datakeys(e.rowindex).value.tostring)             dim carname string = gvbooking.datakeys(e.rowindex).values("car_name").tostring              dim carac string = ""               'dim sql string = ""             'sql = "update dbo.tbl_book set person_name='" + name + "',ac_type='" + carac + "' booking_id = " + id.tostring             'gc.executecommand(sql)             'gvbooking.editindex = -1             'gc.bindgridview(gvbooking, "select * tbl_book")         end sub 

in this, if edit person name henry scott , press update button, finds through debugger nname having value henry only, value before make edit, instead should have value scott edited.

i not understanding making mistake.

please me.

after clicking update, 2 events raised.

1.) gridview.updating : raised before update committed. in event data still not updated in database. event meant dynamic changes applied if required before update method commits changed data database.

2.) gridview.updated event raised after data updated. in event put debug symbol , check value. see new value: scott.

 <asp:gridview id="gridview1" runat="server" onrowupdated="gridview1_rowupdated"></asp:gridview>     

as checking data when update not made.that's why getting original values only. inside gridview1_rowupdated() method check new values.

also, still if want check new values in updating event, use gridviewupdateeventargs.newvalues property [ e.newvalues ] : [ check msdn here ]

  string s = e.newvalues[1].tostring(); // 2nd column // c# sample  

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -