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

Handling errors using Declarative Data Source?

2 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
olav
Top achievements
Rank 1
olav asked on 17 Aug 2010, 03:08 PM
Hi,
I need to create a number of simple pages to display grid-like data, and using a Declarative Data Source (with SqlDataSource) seems like a good idea to save time. But I cannot be sure that the data source is ready at all times. In that case I'd like to simply display an empty grid.

Any suggestions, can (login) errors easily be trapped at some point?
Thanks.

Best,
Olav

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Aug 2010, 02:06 PM
Hello Olav,

By setting the ShowHeadersWhenNoRecords property to "True",  GridNoRecordsItem is shown if there are no records.

And the following docuemntation will be helpful in error handling.
Error handling automatic operations



Thanks,
Princy.
0
olav
Top achievements
Rank 1
answered on 18 Aug 2010, 07:15 PM
Thanks for getting back.
What I meant was error handling in cases like when the database of the connection string does not exist.

Here's how I worked it out for some cases, when I already had tested the connection string:

if (connStringSuccess)
{
    if (RadGrid1.DataSourceID == "")
    {
        RadGrid1.DataSourceID = "MainMSSQL";
        RadGrid1.DataBind();
    }
    else
    {
        RadGrid1.Rebind();
    }
}

Still, no error handling in this case. And if I do not test I'll get an error page if the connection string fails.

Not a very big deal, but a swallowing error handler could be useful for simple and quick pages from time to time, when there's really no other need for writing code.

-olav
Tags
Grid
Asked by
olav
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
olav
Top achievements
Rank 1
Share this question
or