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

Set static value and empty table

6 Answers 288 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sonic
Top achievements
Rank 1
Sonic asked on 28 Sep 2008, 01:20 AM

1. We need to show the filtered time in report header.
 A textbox added to the position, and assigned to the time string, but empty showed after generation.
2. We need to show empty table when the report query no record, but when i set the datasource to empty IEnumerable<BusinessObject> or null, such error appear as following:

#ERROR# The expression contains object 'CategoryName' that is not defined in the current context.

Appreciated for any response.

6 Answers, 1 is accepted

Sort by
0
Sonic
Top achievements
Rank 1
answered on 28 Sep 2008, 06:46 AM
the frist problem we use textbox.value = time.ToShortDayString() programmatically, which cause empty result
0
Rossen Hristov
Telerik team
answered on 29 Sep 2008, 08:32 AM
Hello Sonic,

1. You do not need to do this manually since Telerik Reporting supports formatting out-of-the-box. Simply bind your TextBox to the DateTime column in your data source, select its Format property while in design-time and click the ellipsis. There go to "Date & Time" and select the first entry in the list, i.e. the short date format. Alternatively you can directly type in "{0:d}" in the Format property box. Telerik Reporting supports the standard .NET string formatting, so you can use any standard format.

2. You do not need to set the data source to an empty IEnumerable. Simply set it to null. And in the case where you set it to null -- unbind the TextBox, i.e. set its value to whatever you would like to appear on the report, for example "No Data" or string.Empty.

Please, do not hesitate to contact us if you have any other questions.

Sincerely yours,
Ross
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sonic
Top achievements
Rank 1
answered on 03 Oct 2008, 02:39 AM
sorry for the lack of the issue infomation. I use the datasource to set the daily order report data. And in report header, i need to display the report date, my question is about that report date. after all we can't transfer the date  to datasource again(it was used by order data), so i have to set it's value programatically
0
Rossen Hristov
Telerik team
answered on 03 Oct 2008, 12:17 PM
Hi Sonic,

Now I see what you mean. In this case you should use the built-in function Now() which returns the current moment. So TextBox.Value should become: "=Now()" and TextBox.Format should be "{0:d}". More information on available built-in functions and fields you can find in the "Using Expressions" help article. I hope this information helps.

Sincerely yours,
Ross
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sonic
Top achievements
Rank 1
answered on 05 Oct 2008, 10:38 AM
Appreciatged for the patient reply, after all, we have gone further into the question.
We can set the daily order date now,  but if i want to generate the monthly report or even in user selected date range(really have this function). We maybe even need to display the reporter name.
So i want to make sure one point: whether can we directly set the text box value(sometimes it's really flexible and useful), if we can't, how can we display dynamicly and programatically generated information in the report.
0
Steve
Telerik team
answered on 07 Oct 2008, 03:41 PM
Hello Sonic,

We are not aware of your exact scenario and where do you get the date from, but it is possible to achieve your scenario by exposing properties for it and using the ItemDataBound events to populate the dates or even using Report Parameters and declaratively binding the textboxes to "=Parameters.StartDateParam", "=Parameters.EndDateParam" etc.

Greetings,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Sonic
Top achievements
Rank 1
Answers by
Sonic
Top achievements
Rank 1
Rossen Hristov
Telerik team
Steve
Telerik team
Share this question
or