﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Wed, 18 May 2011 04:41:41 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;Hi Martin&lt;/p&gt;
&lt;p&gt;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 -&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;        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";
&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;Regards&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;Robert&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Tue, 17 May 2011 22:42:29 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hi Robert,&lt;/p&gt;
&lt;p&gt;Glad to hear you have found a workaround.&lt;/p&gt;
&lt;p&gt;So, it is kind of similar with the previous code but now you simply set each cell with your defined CssClass.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;-Martin-&lt;/p&gt;</description></item><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Mon, 16 May 2011 05:03:03 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;Thanks, Martin&lt;/p&gt;
&lt;p&gt;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 -&lt;/p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;
gridRow.Cells[i].Style.CssClass &amp;#43;= "classname"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;;&lt;/span&gt;&lt;/span&gt;

&lt;p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;Regards&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;Robert &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Fri, 13 May 2011 17:32:55 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Try to use the following code to add the cell manually:&lt;/p&gt;&lt;pre&gt;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";&lt;/pre&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;-Martin-&lt;/p&gt;</description></item><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Wed, 11 May 2011 16:53:07 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thank you for your reported issue.&lt;/p&gt;
&lt;p&gt;I have successfully replicated your issue on my end here.&lt;/p&gt;
&lt;p&gt;Regarding the exception error, I will need to discuss further with the development team.&lt;/p&gt;
&lt;p&gt;I will let you know the update when I heard news from the team.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;-Martin-&lt;/p&gt;</description></item><item><title>Adding cells individually to unbound WebGrid throws exception in Render</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Adding-cells-individually-to-unbound-WebGrid-throws-exception-in-Render/</link><pubDate>Wed, 11 May 2011 06:31:30 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;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".&lt;/p&gt;
&lt;p&gt;This can be seen in the Hierarchical_Unbound_Programmatic tutorial, by replacing, say, &lt;/p&gt;&lt;pre&gt;childRows[10].Cells.SetItemData(new object[] { "PS1372", "Computer Phobic AND Non-Phobic Individuals: Behavior Variations", "Psychology", 14.69 });&lt;/pre&gt;

&lt;p&gt;by &lt;/p&gt;&lt;pre&gt;        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"));&lt;/pre&gt;
&lt;p&gt;When this is run, RenderControl throws the exception.&lt;/p&gt;</description></item></channel></rss>