Home > DeveloperSection > Forums > How to find a Row in Datagridview and update it
Jeet Verma
Jeet Verma

Total Post:110

Posted on    January-28-2014 12:14 AM

 C# C# 

 1 Reply(s)
 724  View(s)
Rate this:

I can show data in GridView, now I need find a row with user input in DataGridView so the cursor moves to this row, get this row and update the field (I want updated fields in a textbox on the form , after update), show updated row in datagridview and cursor move to next row automaticaly

Can someone help me?

Pravesh Singh

Total Post:411

Posted on    January-28-2014 12:57 AM

Hi Jeet,

let's say you'r binded data artifact (class is MyData)

public class MyData

   public string Name {get;set;}

   public string Address {get;set}


so yuo have somewhere a collection of of MyData like List<MyData>

List<MyData> myDataList = new List<MyData>();

and do somewhere in the code, I presume, something like this:


Now, yo want to find some row on DataGrid, but you really want is to find a data. So, make a query over the myDataList to find MyData object of interest, let's say like this

var foundMyData = from data in myDataList where (. condition..) select data;

We found the data we interested in, so no let-\'s make it selected on UI. So find the index of the foundMyData in the list and select corresponding row on the grid.

If you use Sorting, or View so the data visible on the screen can be filtered or sorted, you need to consider that "transformations" too, naturally.

Don't want to miss updates? Please click the below button!

Follow MindStick