This is a migrated thread and some comments may be shown as answers.

Retrieve DataRowView item while data binding table in the subreport

2 Answers 139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 18 Feb 2011, 03:25 AM
Hi,

I have spent few hours trying to find a solution to retrieve the current data (DataRowView) from the ItemDataBinding event. This event is bound to a Table control that sits in the subreport. When I step into the code during debug process, I noticed that the DataObject and RawData returns null value. Does anyone know how to access the DataRowView object in this event?
What I done is to dynamically assign a predefined SqlDataSource in the constructor and hook the ItemDataBinding event to the Table. The code looks like below:

public SubReport(string connectionString, string Id){
    SqlDataSource1.Parameters[0].Value = Id;
    SqlDataSource1.ConnectionString = connectionString;

    TableReport.DataSource = SqlDataSource1;
    TableReport.ItemDataBinding += new EventHandler(TableReport_ItemDataBinding);
}

private

 

void TableReport_ItemDataBinding(object sender, EventArgs e)

 

{

    Telerik.Reporting.Processing.

ReportItemBase item = (Telerik.Reporting.Processing.ReportItemBase)sender;

 

 

 

    string daysAnalysis = item.DataObject["intDaysAnalysis"].ToString(); ----> This line throws exception where item.DataObject is null

 

}


Does anyone have idea how can I work around this issue?

Thanks in advance
Kyle


2 Answers, 1 is accepted

Sort by
0
Dave Bierbaum
Top achievements
Rank 1
answered on 22 Feb 2011, 08:06 PM
I have the same problem. I tried using both the Report1_ItemDataBinding and Report1_ItemDataBound events and in all cases the DataObject property is always null! Any ideas? (Note: I'm not in a sub report in my case, this is the main report)

Thanks,
David
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 23 Feb 2011, 08:48 AM
According to the docs you should use IDataObject and not ReportItemBase: http://www.telerik.com/help/reporting/faq-accessing-items.html.

Also the ItemDataBinding is too early to get the data as it fires just before the report is bound to data: http://www.telerik.com/help/reporting/using-report-events.html

Cheers!
Tags
General Discussions
Asked by
Kyle
Top achievements
Rank 1
Answers by
Dave Bierbaum
Top achievements
Rank 1
Massimiliano Bassili
Top achievements
Rank 1
Share this question
or