Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1230
Insert doesn't fill all the data
posted

Asp.Net 2013 Vol 1.

CLR 4.5

Situation:

WebHierarchicalDataGrid with datasource "well" defined.

I have Two tables

The first table contains an ID used by the second as a reference

(typically, the first table is the company and the second table is a site of the company and of course, the site table contains a CompanyID field).

Data are very well displayed.

Editing is allowed.

when I edited a row, everything works fine.

When I want to add a row, the CompanyID is not automatically set so there is an SQL error saying the field is empty. If a put the value of the CompanyID

in the field, the insert works fine. 

So the question is simple : What do I have to do in order to make the filling of this field automatically ? 

Thanks

  • 20255
    Offline posted

    Hi Nicolas,

     I'm just following up to see if you need any further assistance with this issue. If so please do not hesitate to contact me.

  • 20255
    Verified Answer
    Offline posted

    Hello Nicolas,

     I have made a sample that demonstrates this approach, make the filling of the ID field automatically. Handle the RowExpanded event of the WebDataGrid, get the value of the ID field and set it to the ID field cell of the nested grid:

    <script type="text/javascript">
            function WebHierarchicalDataGrid1_ContainerGrid_RowExpanded(sender, eventArgs) {
                var rowID = eventArgs.get_row().get_rowIslands()[0].get_parentRow().get_cellByColumnKey("ID").get_value();
                eventArgs.get_row().get_rowIslands()[0].get_behaviors().get_editingCore().get_behaviors().get_rowAdding().get_row().get_cellByColumnKey("ID").set_value(rowID);
            }
    </script>

      If you have any further questions regarding this don't hesitate to contact me!

    RowAddingWHDG.zip