Telerik Reporting

The various report Section objects expose these events:

Property Description
ItemDataBinding Fires just before the section is bound to data.
ItemDataBound Fires just after the section is bound to data.

In ItemDataBinding and ItemDataBound events use the "sender" argument of the event handler to get a reference to the section object. From the section object you can reference any of the items the section contains, i.e. TextBoxes, PictureBoxes, etc. You can also use the section DataItem property to access the data fields for the section.

Tip

Be aware that this "sender" section object is of type Telerik.Reporting.Processing.ReportItemBase, not the definition item Telerik.Reporting.ReportItemBase.

The example below demonstrates getting a reference to the detail section of the report and finding a specific TextBox within the section. The example also shows retrieving data source column values for the section and using it to alter the TextBox. In this case if the TextBox is made visible if the "Weight" field value is greater than ten. See the EventsReport in the Visual Studio 2008 examples (find the examples in Start | Telerik | Reporting | Visual Studio 2008 Examples).

CopyC#
private void detail_ItemDataBound(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.DetailSection section = (sender as Telerik.Reporting.Processing.DetailSection);
    Telerik.Reporting.Processing.TextBox extraShipping = (Telerik.Reporting.Processing.TextBox)section.ChildElements.Find("extraShippingCostTextBox", false)[0];
    object val = section.DataObject["Weight"];   

    if (!(val is DBNull) && (Convert.ToDecimal(val)) > 10)
    {
        extraShipping.Visible = true;
    }
    else
    {
        extraShipping.Visible = false;
    }
}
CopyVB.NET
Private Sub DetailSection1_ItemDataBound(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DetailSection1.ItemDataBound
    Dim section As Telerik.Reporting.Processing.DetailSection = TryCast(sender, Telerik.Reporting.Processing.DetailSection)
    Dim extraShipping As Telerik.Reporting.Processing.TextBox = DirectCast(section.ChildElements.Find("extraShippingCostTextBox", False)(0), Telerik.Reporting.Processing.TextBox)
    Dim val As Object = section.DataObject("Weight")

    If Not (TypeOf val Is DBNull) AndAlso (Convert.ToDecimal(val)) > 10 Then
        extraShipping.Visible = True
    Else
        extraShipping.Visible = False
    End If
End Sub

See Also