Adding cells individually to unbound WebGrid throws exception in Render

5 replies. Last post: May 18, 2011 4:45 AM by Robert Pehrson
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

An unbound hierachical WebGrid renders successfully if each row's cells are added in one call of SetItemData.  But if the cells are added individually, RenderControl throws exception "Object reference not set to an instance of an object".

This can be seen in the Hierarchical_Unbound_Programmatic tutorial, by replacing, say,

childRows[10].Cells.SetItemData(new object[] { "PS1372", "Computer Phobic AND Non-Phobic Individuals: Behavior Variations", "Psychology", 14.69 });

by 

        childRows[10].Cells.Add(new WebGridCell("PS1372"));
        childRows[10].Cells.Add(new WebGridCell("Computer Phobic AND Non-Phobic Individuals: Behavior Variations"));
        childRows[10].Cells.Add(new WebGridCell("Psychology"));
        childRows[10].Cells.Add(new WebGridCell("14.69"));

When this is run, RenderControl throws the exception.

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