Handling errors using Declarative Data Source?

3 posts, 0 answers
  1. olav
    olav avatar
    10 posts
    Member since:
    Jan 2007

    Posted 17 Aug 2010 Link to this post

    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. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. olav
    olav avatar
    10 posts
    Member since:
    Jan 2007

    Posted 18 Aug 2010 Link to this post

    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
Back to Top