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

NeedDatasource Event Handler

8 Answers 342 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lynn Tietjen
Top achievements
Rank 1
Lynn Tietjen asked on 28 May 2009, 10:05 PM
I am trying to make a user-friendly message that says "No Results" if the datasource comes back empty. The only problem is that the NeedDatasource event handler even when it is in the ASPX code behind does not allow for any changes to the web page once it fires. The page rendering must happen before that event. Does any one have any suggestions how to implement this "No Results" feature. I don't know why Telerik Reports wouldn't have an EmptyTemplate sort of thing.

8 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 01 Jun 2009, 03:13 PM
Hi Lynn Tietjen,

You can use the following code as a temporary workaround for the moment:

void Report1_NeedDataSource(object sender, EventArgs e)
{
    HttpContext.Current.Response.Write("<html><body style='text-align:center'><span><b>No data</b></span></body></html>");
    HttpContext.Current.Response.End();
}


A proper functionality will be implemented in a future version of the Reporting tool. Thank you for the suggestion.

Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dave
Top achievements
Rank 1
answered on 17 Sep 2009, 03:13 AM
Is there a proper solution to this issue yet?  I am having the same problem and this work around will not work as I am also using some sample code from another post to pass report params to a stored procedure and I am making use of the needdatasource function for that. 

Thanks,
Dave
0
Chris Gillies
Top achievements
Rank 1
answered on 17 Sep 2009, 08:30 AM
Looking at the Q2 release notes (http://www.telerik.com/products/reporting/whats-new/release-history/q2-2009-version-3-1-9-701.aspx), there does not seem to be an out of the box way yet. But you can easily use this for your scenario as well - simply make a check if your datasource returns any rows and if it doesn't use the "No data".
0
Michael Love
Top achievements
Rank 1
answered on 29 Oct 2009, 03:24 PM
You mention this...

But you can easily use this for your scenario as well - simply make a check if your datasource returns any rows and if it doesn't use the "No data".

Where in the code behind do you check this when you are setting your data source on the fly?

Mike
0
Chris Gillies
Top achievements
Rank 1
answered on 29 Oct 2009, 03:41 PM
When you say "on the fly", do you refer to NeedDataSource event or hardcoding a datasource through the designer?
Checking for empty datasource is obviously applicable only through code ..
0
Michael Love
Top achievements
Rank 1
answered on 29 Oct 2009, 07:47 PM
I am referring to the NeedDataSource event. I am executing a Sproc to get my data.

Mike
0
Chris Gillies
Top achievements
Rank 1
answered on 30 Oct 2009, 08:23 AM
So what is holding you back? You can take your stored procedure result in a dataset, then just check that if (dataset != null) then take value else return appropriate message. There are several other approaches to check Sproc return value out there, but I believe this would be the easiest one to implement.

Cheers
0
Pavan
Top achievements
Rank 1
answered on 29 Apr 2012, 06:37 PM
how to handle the exception in telerik reports because we are having very big reports so it may go wrong at any point then we are getting the error mgs with red text .i need to handle this in a good way.

Simply: is there any thing like Try and catch in telerik.
Tags
General Discussions
Asked by
Lynn Tietjen
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Dave
Top achievements
Rank 1
Chris Gillies
Top achievements
Rank 1
Michael Love
Top achievements
Rank 1
Pavan
Top achievements
Rank 1
Share this question
or