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

Table datasource with Binbings is null

2 Answers 376 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tomáš
Top achievements
Rank 1
Tomáš asked on 06 Sep 2012, 06:48 AM
Hi,

i have subreport with datasource containt collection of objects. (So components replicate here). Among other i have panel with 2 tables whitch i want to hide if both tables are empty. Tables is fulfilling by binding datasource: ReportItem.DataObject.nameOfMySubClassCollectionInMainDataSource and its working fine. I try hiding the panel by parameters with conditional formating or manualy in code. But problem is that myTable.DataSource property is always null event in DataBound event. Of course after report starting table contains right data but in code i can't check it. Please help.

here is code, where debuger reports always null value:
private void manPrechodZTable_ItemDataBound(object sender, EventArgs e)
        {
            if ((manPrechodZTable.DataSource == null || (manPrechodZTable.DataSource as ExC_BodTrasy.ExC_Prechod[]).Length == 0))
            {
                this.ReportParameters[1].Value = true;
            }
            else
            {
                this.ReportParameters[1].Value = false;
            }
        }


Thanks,

Tomas Linhart, CZ

2 Answers, 1 is accepted

Sort by
0
Wan
Top achievements
Rank 1
answered on 07 Sep 2012, 10:00 AM
desire the answer......
0
Peter
Telerik team
answered on 19 Sep 2012, 03:59 PM
Hi,

The easiest way to achieve hide the table when no data is available is to set a Binding for a table "header" Textbox.

 Property Path

Expression 

 Parent.Visible

 =IIF(Count(1)>0, True, False)

Check out the attached sample report that illustrates the suggested approach.

Up to the provided code snippet, we have noticed that you had used the Report Parameter definition item instead of the processing counterpart. The definition report parameter value is actually the default value. The sender of the event is always the processing counterpart of the data item and you can use it to access the processing report parameter. For more information check out the Using Report Parameters programmatically.
Additionally the data item's DataSource property returns the declarative data source component, not your data object. Instead to access the data items data you can use the following approach:

var table = (Telerik.Reporting.Processing.Table)sender;
var dataObject = table.DataObject;
var value = dataObject["MyColumn"]
All the best,
Peter
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Tomáš
Top achievements
Rank 1
Answers by
Wan
Top achievements
Rank 1
Peter
Telerik team
Share this question
or