Articles in this section
Category / Section

How to bind a underlying data object property inside the DataTemplate?

1 min read

You can bind the properties from underlying data object inside the template of DataBoundTemplate cell type. GridDataBoundTemplate cell sets GridStyleInfo as DataContext for template. You can pass data object via CellValue2 property in GridStyleInfo using QueryCellInfo event.

In the below code snippet, TextBlock inside template cell directly bound to property in underlying data object.


<syncfusion:GridTreeColumn HeaderText="First Name" MappingName="FirstName">
        <syncfusion:GridStyleInfo CellType="DataBoundTemplate">
                    <TextBlock Text="{Binding Style.CellValue2.LastName}" />


void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
    if (e.Style.CellType == "DataBoundTemplate")
        var node = treeGrid.InternalGrid.GetNodeAtRowIndex(e.Style.RowIndex);
        if (node != null)
            var item = node.Item as EmployeeInfo;
            e.Style.CellValue2 = item;


Sample Links:



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment