how to get the values from grid view in textboxes  
Author Message
jayaraja





PostPosted: Windows Forms Data Controls and Databinding, how to get the values from grid view in textboxes Top

hi all

may be my question will be simple for you but am new to this so please let me know how to do this...
am using a gridview control in my form..
am enabling edit and update control for the grid view


when i click on the edit the label controls changes to textboxes...
and when i enter the new values and clicking on update i should get the values from the textboxes and display it in my form
there are 5 columns in my row which am editing
and i ve 5 textboxes in my form
please tell me how to get the values from the edited row to the textboxes ..

tnx




Windows Forms31  
 
 
Badri Narayanan





PostPosted: Windows Forms Data Controls and Databinding, how to get the values from grid view in textboxes Top

You need to handle RowUpdated event of GridView control. When you click the Update button, this event gets fired which has two properties in its event args (GridViewUpdatedEventArgs), OldValues and NewValues. Access these properties to get the modified values.


 
 
jayaraja





PostPosted: Windows Forms Data Controls and Databinding, how to get the values from grid view in textboxes Top

please ..

can you put it in more clear cause am new to this....


please with the source code please....



 
 
Badri Narayanan





PostPosted: Windows Forms Data Controls and Databinding, how to get the values from grid view in textboxes Top

Go to the design mode of the web form, select grid and attach (in the properties window select the events icon) a handler to the RowUpdating event handler (double click the RowUpdating entry to create a handler in the code behind). In the code behin you can access the "e" event arguments properties. Access e.OldValues and e.NewValues to access the edited rows old and new values. These properties are of type Dictionary. Access data via the indexer with syntaxt e.NewValues[0], e.NewValues[1] etc. The indexes are based on the column positions i.e. 0 refers to first column and so on.

HTH


 
 
jayaraja





PostPosted: Windows Forms Data Controls and Databinding, how to get the values from grid view in textboxes Top

thanks for your post...

it really helped me a lot..

tnx again