WebGrid in unbound mode throws NullReferenceException in RenderControl

2 replies. Last post: March 24, 2011 6:08 AM by Robert Pehrson
Tags :

I am adding an unbound WebGrid into an existing project, and my call to the WebGrid's RenderControl is throwing NullReferenceException.  I have no problem when building the unbound WebGrid in isolation, so I guess that something in the project infrastructure is causing problems but cannot see what this could be.  It is as though the grid is expecting a datasource and then failing because DataSource is null.  Are there properties that are used to signal unbound mode in RenderControl other than the DataSource? 

I note that all data-bound operations should be disabled in unbound mode, and I believe that I've done so, but wonder if an omission here could be the cause of the problem.  If so, what exactly are the operations to be disabled?

Answers

Hi Lily,

Thanks for your reply - happily I've now got past the exception in RenderControl.

I've been working from the Hierarchical_Unbound_Programmatic tutorial, and a straight run through works fine.  The problem arises when I try to integrate into our project environment, building the control on demand and picking up the data structure and data from our data objects - it was hard to tell what was causing the crash in RenderControl.  It turns out that I was giving more values in the data array (table.Rows.AddRange) than there were columns in the table; once the right number of values are provided, I get through RenderControl OK. 

Regards,

Robert

All Replies

Hi Robert,

Have you tried to follow our sample about unbound WebGrid? It should be working fine if you follow our sample. But if the problem still occurs, please tell me more details so that I can replicate your issue. Did you call any function in your unbound WebGrid?

When you operate an unbound WebGrid, all the databound features should be disabled and flypostback process as well.


Regards,
Lili Khiung

Hi Lily,

Thanks for your reply - happily I've now got past the exception in RenderControl.

I've been working from the Hierarchical_Unbound_Programmatic tutorial, and a straight run through works fine.  The problem arises when I try to integrate into our project environment, building the control on demand and picking up the data structure and data from our data objects - it was hard to tell what was causing the crash in RenderControl.  It turns out that I was giving more values in the data array (table.Rows.AddRange) than there were columns in the table; once the right number of values are provided, I get through RenderControl OK. 

Regards,

Robert

All times are GMT -5. The time now is 9:29 AM.
Previous Next