locked
how to get modified rows from gridview control in .net 2.0 RRS feed

  • Question

  • I have a DataGrid view control in which i am binding List<T> control  and Gridview control has many rows. user modified 2 rows only, i need only that two rows to send to database SqlServer.

    Sunday, June 7, 2009 9:00 AM

Answers


  • if you are binding to a list control and each list item contains an object. then you can add a property in object like isModified and you can set it to true. when you want to update those changes to database then iterate list elements and send only those objects those isModified property is set to true.

    OR

    you can maintain a list of indexes in memory like Arraylist , when ever a row is modified add the index of that row in ArrayList . after that send only those objects to Database whose indexes are in ArrayList

    like in ArrayList you have 5,8,20 then you can send them easily with index
    • Edited by yazeem Monday, June 8, 2009 4:48 AM
    • Proposed as answer by Ravikiran.Doredla Wednesday, June 10, 2009 10:19 AM
    • Marked as answer by Zhi-Xin Ye Thursday, June 11, 2009 11:29 AM
    Monday, June 8, 2009 4:33 AM

All replies


  • if you are binding to a list control and each list item contains an object. then you can add a property in object like isModified and you can set it to true. when you want to update those changes to database then iterate list elements and send only those objects those isModified property is set to true.

    OR

    you can maintain a list of indexes in memory like Arraylist , when ever a row is modified add the index of that row in ArrayList . after that send only those objects to Database whose indexes are in ArrayList

    like in ArrayList you have 5,8,20 then you can send them easily with index
    • Edited by yazeem Monday, June 8, 2009 4:48 AM
    • Proposed as answer by Ravikiran.Doredla Wednesday, June 10, 2009 10:19 AM
    • Marked as answer by Zhi-Xin Ye Thursday, June 11, 2009 11:29 AM
    Monday, June 8, 2009 4:33 AM
  • Thanks a lot for quick reply. Thak you very much.
    Wednesday, June 10, 2009 10:08 AM