How to find a Row in Datagridview and update it

Total Post:110


 1426  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?
  1. Re: How to find a Row in Datagridview and update it

    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.

      Modified On Apr-04-2018 02:08:56 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.