I have a dataset, obtained from a webservice which contains 2 tables (a parent and child). I am presently binding it to the webhierarchicaldata grid. I presently have a bound checkbox column from the child table which the user can change. To update the source data, I need to send the webservice the changes from the dataset (via the GetChanges dataset method). How can I obtain which child rows have been changed on the server side (after user clicks an ASP button - Save)?
Thanks,
Hung
Hello,
You can handle the RowUpdating event (or each other event corresponding to a CRUD operation - RowAdding, RowDeleting) and get this information from the event argument. Since e.Row will return references to the edited rows from both the parent and child bands, you can check the Level of the row (0 corresponds to parent, 1 corresponds to 1st level child and so on) and if the row comes from a child band you can add it to a list like this:
List rows = new List();if (((ContainerGridRecord)e.Row).Level == 1) { rows.Add(e.Row); }
You can also get e.Values to get collection of the updated values for the row.
I hope this helps. If you have any further questions, please do not hesitate to contact me, I will be glad to help.
So I added the following on my code behind, but if I put a breakpoint on it, I notice it does not fire. What other changes could be needed?
Private Sub WebHierarchicalDataGrid1_RowUpdating(sender As Object, e As Infragistics.Web.UI.GridControls.RowUpdatingEventArgs) Handles WebHierarchicalDataGrid1.RowUpdating
'Dim rows As New List()
If DirectCast(e.Row, ContainerGridRecord).Level = 1 Then
'rows.Add(e.Row)
End If
End Sub
From ASP Page:
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="350px"
Width="100%" DataKeyFields="RoleID" DataMember="Parent" AutoGenerateBands="false"
AutoGenerateColumns="False" >
<Columns>
<%
-- <ig:BoundDataField Key="ID" DataFieldName="ID">
<Header Text="ID" />
</ig:BoundDataField>--
%>
<ig:BoundDataField Key="RoleID" DataFieldName="RoleID">
</ig:BoundDataField>
<ig:BoundDataField Key="Name" DataFieldName="Name">
<Header Text="Name" />
</Columns>
<Bands>
<ig:Band Key="ChildBand_0" DataKeyFields="RoleID,PRODUCT_CATEGORY_ID" DataMember="Child"
AutoGenerateColumns="False">
<ig:BoundDataField Key="PRODUCT_CATEGORY_ID" DataFieldName="PRODUCT_CATEGORY_ID">
<Header Text="PRODUCT_CATEGORY_ID" />
<ig:BoundCheckBoxField DataFieldName="ALLOW_FLAG" Key="ALLOW_FLAG" >
<Header Text="Permit" />
</ig:BoundCheckBoxField>
<ig:BoundDataField DataFieldName="SORT_ORDER_CODE" Key="SORT_ORDER_CODE" Hidden="true">
<Behaviors>
<ig:EditingCore >
<ig:CellEditing>
<ColumnSettings>
--<ig:EditingColumnSetting ColumnKey="ID" ReadOnly="true" />--%>
<ig:EditingColumnSetting ColumnKey="RoleID" ReadOnly="true" />
<ig:EditingColumnSetting ColumnKey="PRODUCT_CATEGORY_ID" ReadOnly="true" />
<ig:EditingColumnSetting ColumnKey="ALLOW_FLAG" />
<ig:EditingColumnSetting ColumnKey="SORT_ORDER_CODE" ReadOnly="true" />
</ColumnSettings>
<EditModeActions MouseClick="Single" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>