I have a WHDG that is using the RowEditingTemplate to populate the child row (one band). The template contains a DropDownList. I need to populate the DDL in code with the values. I cannot find the DDL in the grid in the code behind. I have done this successfully before with a WebDataGrid using the following code.
Dim dropDownList As DropDownList
dropDownList = CType(wdgLoanEstimate.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("ddlLoanCostGroupValue"), DropDownList)
For the WHDG I am using the following. There are no controls in the TemplateContainer even though by RowEditTemplate contains my ClientBindings and the controls are visible on the template when executed.
dropDownList = CType(whdgLoanEstimate.GridView.Bands(0).Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("ddlLoanCostGroupValue"), DropDownList)
<ig:WebHierarchicalDataGrid ID="whdgLoanEstimate" runat="server"
DataKeyFields="LoanCostTypeValue"
InitialDataBindDepth="1"
InitialExpandDepth="1"
Style="z-index: 102; left: 0px; position: absolute; top: 26px"
Width="760px">
<Bands>
<ig:Band Key="LoanAppEstimateCostRecID"
DataMember="LoanCostItemChild"
DataKeyFields="LoanAppEstimateCostRecID"
AutoGenerateColumns="false"
ExpansionColumnCss="GridExpandColumnNone">
<Behaviors >
<ig:EditingCore >
<ig:CellEditing Enabled ="true" ></ig:CellEditing>
<ig:RowAdding AddNewRowCssClass ="hideRowTemplate"></ig:RowAdding>
<ig:RowEditingTemplate CancelButton ="buttonCancel" OKButton ="buttonOK">
<EditModeActions MouseClick ="Single" />
<ClientBindings >
<ig:RowEditingClientBinding ColumnKey ="LoanCostGroupValue" ControlID ="ddlLoanCostGroupValue"
GetValueJavaScript="$get({ClientID}).value"
SetValueJavaScript="$get({ClientID}).value={value} == null ? '' : {value}" />
</ClientBindings>
<Template>
<div style="background-color:white;border:1px solid black; ">
<table border="0" >
<tr>
<td>
<asp:Label ID="lblLoanCostGroupValue" runat="server" Text="Group" />
</td>
<asp:DropDownList ID="ddlLoanCostGroupValue" runat="server"
style="z-index: 100000;"></asp:DropDownList>
</tr>
<asp:Button ID="buttonOK" runat="server"
OnClientClick="return"
Text="OK"
UseSubmitBehavior="False" />
<asp:Button ID="buttonCancel" runat="server"
CausesValidation="False"
Text="Cancel"
</table>
</div>
</Template>
</ig:RowEditingTemplate>
</Behaviors>
</ig:EditingCore>
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>
Hello,
Thank you for contacting us!
About your question, in order to access the child RowEditTemplates you should use RowIslands collection. I have created a sample for you that will show you how to change the Button Text for both parent and child RET( for first row only).
Code snippet:
protected void Button1_Click(object sender, EventArgs e) { //Change OK btn text in both parent row and first child island (WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("buttonOK") as Button).Text = "Some text"; (WebHierarchicalDataGrid1.GridView.Rows[0].RowIslands[0].Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("buttonOK") as Button).Text = "Some text"; }
I hope you will find my sample helpful
Thanks. I realized something when I read your answer; the child row is not present until you bind the data with a parent row. I was trying to load the DDL in the child row prior to binding the data, which is now I did this on the WebDataGrid.
I am glad that I've managed to help you.