Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
Binding an empty dataset to ultrawebgrid
posted

How do I handle grid binding when the dataset is empty?

I get an error at UltraWebGrid.OnLoad() when datasource is empty.

"The IListSource does not contain any data sources."

  • 21382
    posted

    Assuming you are using the System.Data.DataSet object.

    I would assume that you could just take your DataSet object and see if you don't have any tables in it before calling databind.

     

    if (ds.Tables.Count > 1)

    webgrid.DataBind()

     

     The behavior is similar to that of the GridView, they both will throw the same exception as it tries to bind.

  • 145
    posted

    I found the problem.

    I had set Dataset = new dataset().

    So when there was no dataset, new Dataset() was passed, in other words zero was passed.

    I set Dataset to return null when there is no data. Its worknig fine.