Wednesday, August 18, 2010

Code for Updating Datagrid on c#?

hi,





i am new to .net. any one please give me code for updating a data grid using c#. or plz tell me how to get the updated cell value?


thanks.Code for Updating Datagrid on c#?
Well it depends on a couple of things. I will assume C# 2.0 and that you are using the DataGridView on a Windows app.





It also depends on how you are selecting the row which contains the data to update. Remember that a DataGridRow is an object, so you need to find that row first.





But here is how you would change the value in the First column of the First row:





myGrid.Rows[0].Cells[0].Value = ';Some Value';;





If you already have the row in hand, perhaps by using a for loop, you could just do:





myRow.Cells[0].Value = ';Some Value';;





Again, it all depends on the context.

No comments:

Post a Comment