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>
Also should mention this error appears as well...
Error 7 Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
Protected Sub whdg_RowUpdating(sender As Object, e As RowUpdatingEventArgs) Handles whdg.RowUpdating
rows.Add(e.Row)
Dim vals = e.Values.ToString()
I believe there is an error with misspelling the grid's id. The code I have shared in the post uses "WebHierarchicalGrid1" as an id of the grid, but in my sample I actually used the much more simple "whdg". Please make sure the id of the grid used in the code behind matches the id set in the markup.
They are the same, but I still get the error.
<ig:WebHierarchicalDataGrid ID="whdg" runat="server" Height="480px" Width="732px"
DataMember="Parent" Key="Parent" DataKeyFields="ID" AutoGenerateBands="False"
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
whdg.DataSource = populateDataSet()
whdg.DataBind()
Error 1 'whdg' is not declared. It may be inaccessible due to its protection level. Default.aspx.vb 14 9 WHG_TEST_INFRA
Error 2 'whdg' is not declared. It may be inaccessible due to its protection level. Default.aspx.vb 15 9 WHG_TEST_INFRA
Error 3 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. Default.aspx.vb 71 89 WHG_TEST_INFRA
I would like to kindly ask you to clarify if you see this error when compiling the attached sample or you happen to see it on a different one. If this is the case please send the sample that throws this error so that we could be able to investigate it for you.
Hello,If you need any further assistance on the issue, please feel free to contact me, I will be glad to help you.
There were some issues because of the previous conversion of the sample (project to website and vice versa). I modified it and now the RowUpdating event fires correctly and the error it used to receive is now gone (Error 7 Handles clause requires a WithEvents variable defined in the containing type or one of its base types.)
I hope this helps.
Thank you for choosing Infragistics components !
It is a VS2010 project running .NET 4.0
I have looked at that and it fires for me. Can you just attach the latest version of the project so we can be sure that we are working on the same things?
Thank you.
Thanks, that removed the error and allowed me to run the code. However, if I place a breakpoint on whdg_RowUpdating, I never see it fire. I am checking and unchecking the checkboxes.