New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

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">

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


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)
    if (e.DetailTableView.DataMember == "OrderDetails")
        daOrderDetails.SelectCommand.CommandText = "Select * from [Order Details] where OrderID = " + parentItem["OrderID"].Text;
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
    End If
    If (e.DetailTableView.DataMember = "OrderDetails") Then
        daOrderDetails.SelectCommand.CommandText = "Select * from [Order Details] where OrderID = " + parentItem("OrderID").Text
    End If
End Sub

For more details and examples check out the dedicated article: Hierarchical data-binding using DetailTableDataBind event.

See Also

In this article