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
140
Force column generation in binding UltraWebGrid to empty table
posted

Hi!

Is it possible to force the grid to generate columns even though the table has 0 rows?  I dropped a grid on an aspx page in the designer and after binding a dataset which has a table with 0 rows, the columsn do get generated (so the user can see that the report did run but dodn't generate any data).  Note: I have AutoGenerateColummns = true (in the designer).

 Then, as a test, on another page, I create a grid programmatically, using:

UltraWebGrid grid = new UltraWebGrid("UltraWebGrid1");

and set AutoGenerateCOlumns to true.

However, after:

grid.DataSource = ds.Tables[0];

grid.DataBind();

I get "Object not set (NullReference)" exception.

So, the question is: how is it that when created in the designer the grid does generate columns gracefully, but when created dynamically, the grid throws an exception on DataBind() ?

Thanks in advance!

Regards,

S

 

Parents
No Data
Reply
  • 8680
    posted

    If you're trying to force the column headers/footers to render when there are no rows, I don't know of a way to do that.  Maybe someone else does.

    I could be wrong, but it sounds to me like you don't even have an empty table in ds.Tables[0].

    But in either case, you might consider detecting the null/empty DataTable, and either A) Open the AddNew row, or B) generate a row full of empty (null, "") values.

     

Children