Skip to main content

ASPxTreeList.FindDataCellTemplateControl(String, TreeListDataColumn, String) Method

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

Namespace: DevExpress.Web.ASPxTreeList

Assembly: DevExpress.Web.ASPxTreeList.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public Control FindDataCellTemplateControl(
    string nodeKey,
    TreeListDataColumn column,
    string id
)

Parameters

Name Type Description
nodeKey String

A String value that identifies the node.

column TreeListDataColumn

A TreeListDataColumn object 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 node.

id String

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

Returns

Type Description
Control

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

Remarks

To learn more, see Templates.

Example

In this example, the ASPxTreeList.HtmlRowPrepared event is handled to display appropriate images within data cells. The ASPxTreeList.FindDataCellTemplateControl method is used to access ASPxImage and ASPxLabel template controls contained within data cells.

The image below shows the result:

cdAccessTemplateCtrls

protected void ASPxTreeList1_HtmlRowPrepared(object sender,
DevExpress.Web.ASPxTreeList.TreeListHtmlRowEventArgs e) {
    if(e.RowKind != DevExpress.Web.ASPxTreeList.TreeListRowKind.Data) return;
    ASPxImage img = ASPxTreeList1.FindDataCellTemplateControl(e.NodeKey,
      ASPxTreeList1.Columns["Product"] as TreeListDataColumn, "ASPxImage1") as ASPxImage;
    ASPxLabel lb = ASPxTreeList1.FindDataCellTemplateControl(e.NodeKey,
      ASPxTreeList1.Columns["Product"] as TreeListDataColumn, "ASPxLabel1") as ASPxLabel;
    if (ASPxTreeList1.FindNodeByKeyValue(e.NodeKey).HasChildren) {
        img.ImageUrl = @"~\i\product-group.png";
        lb.Font.Size = 12;
        lb.Font.Bold = true;
    }
    else
        img.ImageUrl = @"~\i\product.png";
}
See Also