Back to Devexpress

ASPxGridView.FindRowCellTemplateControlByKey(Object, GridViewDataColumn, String) Method

aspnet-devexpress-dot-web-dot-aspxgridview-dot-findrowcelltemplatecontrolbykey-x28-system-dot-object-devexpress-dot-web-dot-gridviewdatacolumn-system-dot-string-x29.md

latest3.5 KB
Original Source

ASPxGridView.FindRowCellTemplateControlByKey(Object, GridViewDataColumn, String) Method

Searches for the server control contained within the specified data cell‘s template.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public Control FindRowCellTemplateControlByKey(
    object rowKey,
    GridViewDataColumn gridViewDataColumn,
    string id
)
vb
Public Function FindRowCellTemplateControlByKey(
    rowKey As Object,
    gridViewDataColumn As GridViewDataColumn,
    id As String
) As Control

Parameters

NameTypeDescription
rowKeyObject

An object that uniquely identifies the row.

| | gridViewDataColumn | GridViewDataColumn |

A GridViewDataColumn descendant that represents the data column where the requested cell resides. If null ( Nothing in Visual Basic), the search is performed within all cells in the specified row.

| | id | String |

A String value that identifies the control within the specified cell.

|

Returns

TypeDescription
Control

A Control object that represents the control contained within the specified data cell’s template.

|

Remarks

For more information, see Templates.

aspx
<dx:ASPxGridView ID="Grid" runat="server" OnHtmlRowPrepared="Grid_HtmlRowPrepared" ...>
    <Columns>
        <dx:GridViewDataTextColumn FieldName="Name">
            <DataItemTemplate>
                <dx:ASPxButtonEdit ID="ButtonEdit" runat="server">
                    <!-- ... -->
                </dx:ASPxButtonEdit>
            </DataItemTemplate>
        </dx:GridViewDataTextColumn>
    </Columns>
    <!-- ... -->
</dx:ASPxGridView>
csharp
protected void Grid_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) {
    ASPxButtonEdit buttonEdit = Grid.FindRowCellTemplateControlByKey(e.rowKey,
        Grid.Columns["Name"] as GridViewDataColumn, "ButtonEdit") as ASPxButtonEdit;
    // ...
}
vb
Protected Sub Grid_HtmlRowPrepared(ByVal sender As Object, ByVal e As ASPxGridViewTableRowEventArgs)
    Dim buttonEdit As ASPxButtonEdit = TryCast(Grid.FindRowCellTemplateControlByKey(e.rowKey, TryCast(Grid.Columns("Name"), GridViewDataColumn), "ButtonEdit"), ASPxButtonEdit)
    ' ...
End Sub

See Also

Grid View

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace