locked
DataGridView - Updating record using seperate form RRS feed

  • Question

  • Hi,

      I am currently using VC++/Cli 2005.  In a project, I'm using a DataGridView control to show records from a SQL 2005 table.  Instead of updating a specific item directly within DataGridView control, I would like to open a new form and allow user to update selected record/item within that form.   The reason to update this way is conditionned by the fact that I have 3 levels of detail as following:

                       Level 0           Level 1               Level 2

                                    1:N                    1:N
                     Furniture --> Component --> Component

      You all understand that update form of Level1 will/must include, as Level0 do, another DataGridView control to display/detail all related items issued from next level.  This explains why I can't allow user to update Level 1 directly from DataGridView control.

      I've searched in MSDN and even bought a few books on subject but unfortunately I found nothing on how to do it this way.   All articles on DataGridView control were only showing how to update record directly from control.

      My approach, I think, would be to transmit to my level1 updating form, as a single parameter, the selected DataRow object (or a brand new one if currently adding) issued from DataGridView and let user update it's content.  When User finally leaves level0 update form, then I presume that DataGridView corresponding table would be automatically updated according to DataGridView's content. 

      What would be the proper way to do it?  I would certainly appreciate to hear you view on this.

      Also, what can I do if I want to refresh DataGridView's content when coming back from update form.  Is it done automatically?  I would certainly be sure that it reflects the reality, not only when I update it myself but also especially when other users could concurrently update same records?

    Thanks in advance,

    Stéphane

    Tuesday, December 5, 2006 7:37 PM

Answers