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

SubReport/Textbox issue!

2 Answers 103 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fatima Mohey
Top achievements
Rank 1
Fatima Mohey asked on 15 Oct 2009, 03:28 PM
hey guys,
 i've a little problem here, i created a method in a report (report x), takes 1 parameter to fill the dataset query with this parameter. this report x is used as subreport in another report (report y)....  so i call that method from report y in the textbox bound event with the value of the text box as the parameter like that:

Telerik.Reporting.Processing.TextBox textbox = sender as Telerik.Reporting.Processing.TextBox; 
string myParameter = textbox.Text; 
mysecondReport mysecondReport1 = new mysecondReport(); 
subReport1.ReportSource = mysecondReport1; 
((mysecondReport)subReport1.ReportSource).fill_DataSet(myParameter);  // where fill_DataSet is my method

and this is the code of my method (fill_DataSet) in report x:
public void fill_DataSet(string myParam) 
        { 
 mysecondReportTableAdapter adapter = new mysecondReportTableAdapter(); 
 myDataSet.mysecondReportDataTable table = adapter.GetDataBymyParameter(myParam); 
this.DataSource = table; 

i've breakbpoint all these and the value is passing correctly from the textbox bound event to the other report but the problem in the first time the subreport rendered where it show no data (as if the value didn't pass) , then this value(first textbox) that supposed to be for the subreport (first subreport) is taken instead by the second subreport rendered.
so my output is a subreports with incorrect data, and a missing first subreprot rendering.

hope someone get it and could help me with that.

P.S i can't use need datasource event as the report has its own dataset and i don't want to use parameters.


2 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 16 Oct 2009, 09:24 AM
Hello Fatima,

As described in this help topic from the online help, the ItemDataBound event occurs after the current report/sub-report is data bound which is too late to specify the data source. This explains why the records of your sub-report are shifted one record behind the main report. For each record of the main report the following sequence of events occurs for the sub-report:

1. The ItemDataBinding event occurs just before the sub-report is processed;
2. The NeedDataSource event occurs if the sub-report does not have a data source;
3. The sub-report is processed and its records are added to the generated result;
4. The ItemDataBound event occurs right after the sub-report is processed.

It is evident that if you specify a data source in the ItemDataBound event that data source should not be used until the next iteration, hence the records of the sub-report should lag one record behind the main report. To avoid this you should always specify the data source in the NeedDataSource event of the subreport/report instead which is meant for this sole purpose.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Fatima Mohey
Top achievements
Rank 1
answered on 18 Oct 2009, 04:57 PM
Now i understand.
Thanks Steve!

Tags
General Discussions
Asked by
Fatima Mohey
Top achievements
Rank 1
Answers by
Steve
Telerik team
Fatima Mohey
Top achievements
Rank 1
Share this question
or