Find control in devexpress gridview Templates DetailRow

levi picture levi · Apr 18, 2012 · Viewed 15k times · Source

I want to find control in my gridview.Template detail row by id

        bool IsAllAud = false;
        var item = (CheckBox)VendorsGrid.Templates.DetailRow.FindControl("CBIsAllAudience");
        IsAllAud = item.Checked;
        if (IsAllAud)
        {

        }
<dx:ASPxGridView ID="rt" ClientInstanceName="rt" runat="server"
            AutoGenerateColumns="false" DataSourceID="rtt" KeyFieldName="ID" Width="100%">
            <SettingsDetail AllowOnlyOneMasterRowExpanded="true" />
            <Columns>
                <dx:GridViewDataTextColumn FieldName="Name" Caption="Name" />
            </Columns>
            <Templates>
                <DetailRow>
                    <asp:CheckBox ID="CBIsAllAudience" runat="server" />
...

Answer

Raj Ranjhan picture Raj Ranjhan · Apr 18, 2012

Since this is DetailRow you will need to call ASPxGridView.FindDetailRowTemplateControl Method

var item = VendorsGrid.FindDetailRowTemplateControl(index, "CBIsAllAudience");