none
Table data update RRS feed

  • Question

  • Hi all,

    I have a grid with table data in c sharp project.Is there any way to identify that the user changed the table values or not. I.e. if the user type some different value in the grid I want to identify whether the user changed the values. How may I achieve this? Please help.

    Monday, April 25, 2011 2:38 AM

Answers

  • Anu,

    From DataGridView, I don't think there is a direct way to check a modifed row. Instead, What I can suggest is, every datagridview has a Tab property. Initially you can store 0 (zero) in Tag for all rows. Whenver the row is updated, set the Tag to 1 for that row. Later you can loop through all rows in grid to check which one is modified.

     


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Marked as answer by Creative_Pro Tuesday, April 26, 2011 6:13 AM
    Tuesday, April 26, 2011 5:51 AM

All replies

  • You can check RowState of the rows in table. In below code, I am checking whether a row is modified or not.

    foreach(DataRow row in table.Rows)
    {
        if( row.RowState == RowState.Modified )
        {
            MessageBox.Show ("This row is modified");
        }
    }
    

    RowState also states whether a row is deleted, added, detached or unchanged. You can use them as per your need.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Monday, April 25, 2011 5:28 PM
  • HI Adavesh,

    In the above example, I have a doubt with 'table.rows'. Is that 'table' is the name of the datatable? But I am using linq queris here. i.e. I populate data in the grid using linq query. so I dont have a data table here. So is there any way to do this same thing using linq query or should I create a datatable with my table? Please advice.

    Thanx

    Tuesday, April 26, 2011 3:10 AM
  • Anu,

    From DataGridView, I don't think there is a direct way to check a modifed row. Instead, What I can suggest is, every datagridview has a Tab property. Initially you can store 0 (zero) in Tag for all rows. Whenver the row is updated, set the Tag to 1 for that row. Later you can loop through all rows in grid to check which one is modified.

     


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Marked as answer by Creative_Pro Tuesday, April 26, 2011 6:13 AM
    Tuesday, April 26, 2011 5:51 AM
  • hi Adavesh,

    Thanx for the reply, I will check it out.

    regards.

    Tuesday, April 26, 2011 6:13 AM