c# - Asp.net gridview, get boundfield value in code behind when in edit mode -
I am using gridview and editing mode in asp.net (c #) so that the user can change the value. But I need to check the value that users enter into the envoving, when using this code, I always get the old value that I did not enter. How do I get a new value?
& lt; ASP: GridVid ID = "Mygrid View" onruvdating = "MyZidWoodUpdate" DataName = "ID, Value" & gt; & Lt; Columns & gt; & Lt; ASP: Boundfield Readonly = "Foal" Datafield = "Value" Dataform String = "{0: 0 ##}" /> & Lt; Asp: CommandField ShowEditButton = "true" EditImageUrl = "~ / images / iconedit.png" button type = "image" Cancel ImageUrl = "~ / images / iconclose.png" updated IMAGE URL = "~ / images / icon edit page" / & Gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt;
In Code Behind:
Protected Zero MyGridViewUpdate (Object Sender, GridViewUpdateEventArgs E) {string test = e.NewValues ["value"]. ToString (); // test always assume the old values, I need the user added the new value ..}
You added the value of the ID and values to DataKeyNames property like GridView . DataKeyNames = "id, price"
. It is to specify that they are both primary keys, if you want the value to be editable, then you should delete it from DataKeyNames.
Comments
Post a Comment