DetailTableDataBind Event

Fired when a table from DetailTablesCollection binds to a data source.

Event Parameters

  • (object) sender

    • The control that fires the event
  • (GridDetailTableDataBindEventArgs) e

    • Event arguments

      • (boolean) e.Canceled

        If set to True the event will be canceled

      • (GridTableView) e.DetailTableView

        Gets a reference to the detail table being bound.

Attaching the event

In the Markup

<telerik:RadGrid ID="RadGrid1" runat="server" OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
</telerik:RadGrid>

In the Code behind

protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.DetailTableDataBind += RadGrid1_DetailTableDataBind;
}
Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
    AddHandler RadGrid1.DetailTableDataBind, AddressOf RadGrid1_DetailTableDataBind
End Sub

The event handler

protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
    bool canceled = e.Canceled;
    GridTableView detailTableView = e.DetailTableView;
}
Protected Sub RadGrid1_DetailTableDataBind(ByVal sender As Object, ByVal e As GridDetailTableDataBindEventArgs)
    Dim canceled As Boolean = e.Canceled
    Dim detailTableView As GridTableView = e.DetailTableView
End Sub

Exemples

Hierarchical data-binding

Binding detail tables using database select

private void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
    if (parentItem.Edit)
    {
        return;
    }
    if (e.DetailTableView.DataMember == "OrderDetails")
    {
        dsNWind1.OrderDetails.Clear();
        daOrderDetails.SelectCommand.CommandText = "Select * from [Order Details] where OrderID = " + parentItem["OrderID"].Text;
        daOrderDetails.Fill(dsNWind1.OrderDetails);
    }
}
Private Sub RadGrid1_DetailTableDataBind(ByVal source As Object, ByVal e As GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind
    Dim parentItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
    If parentItem.Edit Then
        Return
    End If
    If (e.DetailTableView.DataMember = "OrderDetails") Then
        dsNWind1.OrderDetails.Clear()
        daOrderDetails.SelectCommand.CommandText = "Select * from [Order Details] where OrderID = " + parentItem("OrderID").Text
        daOrderDetails.Fill(dsNWind1.OrderDetails)
    End If
End Sub
In this article
Not finding the help you need? Improve this article