Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.FindDetailRowTemplateControl(Int32, String) Method

Searches for the server control contained within the specified detail row‘s template.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public Control FindDetailRowTemplateControl(
    int visibleIndex,
    string id
)

Parameters

Name Type Description
visibleIndex Int32

An integer value that identifies the detail row.

id String

A String value that identifies the control within the specified detail row.

Returns

Type Description
Control

A Control object that represents the control contained within the specified detail row’s template.

Remarks

The page’s hierarchy does not contain controls inside a detail row if a master row is not expanded. In this case, the FindDetailRowTemplateControl method returns null.

To access controls within the Detail Row template for a collapsed master row, expand this master row before you call the FindDetailRowTemplateControl method.


if (!ASPxGridViewMaster.DetailRows.IsVisible(ASPxGridViewMaster.FocusedRowIndex)) {                
    ASPxGridViewMaster.DetailRows.ExpandRow(ASPxGridViewMaster.FocusedRowIndex)
}

Example

This example shows how to select rows in a detail grid when the master row selection is changed.

<%-- BeginRegion Page setup --%>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Grid_MasterDetail_SelectDetailRows_Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.1" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%-- EndRegion --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>How to select detail rows on master row selection</title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            function master_RowSelecting(index, state) {
                master.PerformCallback("select|" + index + "|" + (state ? "T" : ""));
            }
        </script>
        <dxwgv:ASPxGridView ID="master" runat="server" AutoGenerateColumns="False" DataSourceID="masterData" KeyFieldName="CategoryID"
            ClientInstanceName="master" OnCustomCallback="master_CustomCallback">
            <SettingsDetail ShowDetailRow="True" />
            <Columns>
                <%-- BeginRegion Custom selection check --%>
                <dxwgv:GridViewDataColumn VisibleIndex="0">
                    <DataItemTemplate>
                        <input type="checkbox"
                            onclick="master_RowSelecting(<%# Container.VisibleIndex %>, checked)" 
                            <%# master.Selection.IsRowSelected(Container.VisibleIndex) ? "checked=\"checked\"" : "" %> />
                    </DataItemTemplate>
                </dxwgv:GridViewDataColumn>
                <%-- EndRegion --%>
                <dxwgv:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="1">
                    <EditFormSettings Visible="False" />
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <%-- BeginRegion Templates --%>
            <Templates>
                <DetailRow>
                    <dxwgv:ASPxGridView ID="detail" runat="server" AutoGenerateColumns="False"
                        DataSourceID="detailData" KeyFieldName="ProductID" OnBeforePerformDataSelect="detail_BeforePerformDataSelect">
                        <Columns>
                            <dxwgv:GridViewCommandColumn ShowSelectCheckbox="true" VisibleIndex="0" />
                            <dxwgv:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="1">
                                <EditFormSettings Visible="False" />
                            </dxwgv:GridViewDataTextColumn>
                            <dxwgv:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2">
                            </dxwgv:GridViewDataTextColumn>
                            <dxwgv:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3">
                            </dxwgv:GridViewDataTextColumn>
                        </Columns>
                    </dxwgv:ASPxGridView>
                </DetailRow>
            </Templates>
            <%-- EndRegion --%>
        </dxwgv:ASPxGridView>

        <%-- BeginRegion DataSources --%>
        <asp:AccessDataSource ID="masterData" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:AccessDataSource>            
        <asp:AccessDataSource ID="detailData" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products] WHERE CategoryID = ?">
            <SelectParameters>                
                <asp:Parameter Name="CategoryID" />                
            </SelectParameters>
        </asp:AccessDataSource>
        <%-- EndRegion --%>            
    </form>
</body>
</html>

The following code snippets (auto-collected from DevExpress Examples) contain references to the FindDetailRowTemplateControl(Int32, String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also