iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
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.
Hi Martin
The workaround is to address the cell after it's been created, either with SetItemData or by assigning to its Text property. The following assigns to the Text property and then writes into the Style of one of the cells. This just sets the BackColor, but I've been setting other properties including CssClass -
childRows[10].Cells[0].Text = "PS1372"; childRows[10].Cells[1].Text = "Computer Phobic AND Non-Phobic Individuals: Behavior Variations"; childRows[10].Cells[2].Text = "Psychology"; childRows[10].Cells[2].Style.BackColor = System.Drawing.Color.Yellow; childRows[10].Cells[3].Text = "14.69";
Regards
Robert
Hello,
Thank you for your reported issue.
I have successfully replicated your issue on my end here.
Regarding the exception error, I will need to discuss further with the development team.
I will let you know the update when I heard news from the team.
Thank you.
Regards,-Martin-
Try to use the following code to add the cell manually:
childRows[10].Cells[0].Text = "PS1372"; childRows[10].Cells[1].Text = "Computer Phobic AND Non-Phobic Individuals: Behavior Variations"; childRows[10].Cells[2].Text = "Psychology"; childRows[10].Cells[3].Text = "14.69";
Thanks, Martin
It does work if I assign just the text to each cell, but that's doesn't get me any further than the original call on SetItemData to assign all texts at once. My problem is that I need to set properties on individual cells as well as their text. I have a workaround now, which is to assign the texts first (which presumably creates the cells), and then select individual cells by index -
Hi Robert,
Glad to hear you have found a workaround.
So, it is kind of similar with the previous code but now you simply set each cell with your defined CssClass.
Do you have a simple runable sample about this scenario? It might be useful for other users if we can create a knowledge base for this one.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname