Hi,
I have a simple webhierarchicaldatagrid, and in the second band I have a template column with a button like the following:
<ig:WebHierarchicalDataGrid ID="wdgLOG" runat="server" AutoGenerateColumns="False"
Height="300" AutoGenerateBands="False" InitialDataBindDepth="-1" Width="100%"
DataKeyFields="Lote" EnableDataViewState="true" EnableAjax="false" DataMember="Files"
Key="Files">
<ExpandCollapseAnimation SlideOpenDirection="Auto" SlideOpenDuration="300" SlideCloseDirection="Auto"
SlideCloseDuration="300" />
<Columns>
……
</Columns>
<Bands>
<ig:Band DataKeyFields="ProcSourceFileID,ProcFileID" AutoGenerateColumns="false"
DataMember="FilesDet" Key="FilesDet" ShowHeader="true">
<ig:TemplateDataField Key="Audit" Width="16px" Header-Text="" Header-Tooltip="Ver Auditoria">
<ItemTemplate>
<asp:LinkButton ID="lbtnAudit" runat="server" Height="16px" CssClass="CmdAbrirAuditoria"
ToolTip="Auditoria" CommandName="CmdAudit" CommandArgument='<%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).Item, "Row.Index") %>'></asp:LinkButton>
</ItemTemplate>
</ig:TemplateDataField>
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>
When I click lbtnAudit Button I want to know what row I'm currently in, so I use ItemCommand Event:
Private Sub wdgLOG_ItemCommand(sender As Object, e As Infragistics.Web.UI.GridControls.HandleCommandEventArgs) Handles wdgLOG.ItemCommand
If e.CommandName = "CmdAudit" Then.....I know that the property CommandArgument gives the current row index and it works perfectly. But I need to know the index of the parent row too, because CommandArgument only gives the current child index...How can I do this?Thank you
Hello Sonia,
Accessing the parent row's index (and the parent row object itself) is possible by handling the templated control's Click event (or alternatively the grid's ItemCommand event) through the sender argument passed to the event. For instance:
GridRecordItem item = ((Infragistics.Web.UI.TemplateContainer)(((System.Web.UI.Control)(sender)).Parent)).Item as GridRecordItem;
var containerGrid = ((Infragistics.Web.UI.GridControls.ContainerGridRecord)(item.Row)).Owner.ControlMain;
var parentRow = containerGrid.ParentRow;
var parentIndex = parentRow.Index;
I'm attaching you also a sample.
If you have any further questions, I'll be glad to help you.
Best Regards,
Tsanna Belcheva
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
I tried doing that but I am getting
The property or indexer 'Infragistics.Web.UI.GridControls.ControlDataRecordCollection.ControlMain' cannot be used in this context because the get accessor is inaccessible
Please help me.
Thank you!