Sorry...but I simply cannot find an answer to this question. I want to access the checkbox shown in read below in code behind.
Thanks in advance!
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" ClientIDMode="Static" ViewStateMode="Disabled" DataKeyFields="ParentOfficeId" DataMember="parent" AutoGenerateColumns="False" runat="server" OnInitializeRow="WebHierarchicalDataGrid1_OnInitializeRow" OnInitializeBand="WebHierarchicalDataGrid1_OnInitializeBand" DefaultColumnWidth="500px" InitialDataBindDepth="1" OnRowIslandsPopulated="WebHierarchicalDataGrid1_OnRowIslandsPopulated"> <Columns> <ig:BoundDataField DataFieldName="name" Key="name" Header-Text="Office" /> </Columns> <Bands> <ig:Band Key="offices" DataKeyFields="ParentOfficeId" DataMember="child" AutoGenerateColumns="False"> <Columns> <ig:TemplateDataField Key="col1" Width="20"> <ig:ItemTemplate> <asp:Label runat="server" Text=" " /> </ig:ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="SelectedOffice" Width="500px"> <ItemTemplate> <asp:CheckBox ID="chkOffice" runat="server" officeId='<%# Eval("Officeid", "{0}") %>' Text='<%# Eval("name", "{0}") %>' /> </ItemTemplate> </ig:TemplateDataField>
</Columns> </ig:Band> </Bands>
</ig:WebHierarchicalDataGrid>
Hello,
Thank you for posting in our community.
To access given control inside of a template column, you can call the FindControl method on that column's cell:
protected void Btn_Click(object sender, EventArgs e) { foreach (ContainerGridRecord row in whdg.Rows) { var rowsOfCurrentBand = row.RowIslands[0].Rows; foreach (ContainerGridRecord bandRow in rowsOfCurrentBand) { CheckBox checkbox = bandRow.Items.FindItemByKey("CheckboxColumn").FindControl("CheckboxID") as CheckBox; checkbox.Checked = true; } } }
I have created and attached a sample illustrating the desired behavior. When the button is clicked all checkboxes on all bands are marked as checked.
If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.
0815.Sample.zip