﻿<?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 - example</title><link>http://www.intersoftsolutions.com/Community/Tags/example/</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>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/Tags/example/</link><pubDate>Mon, 07 Jun 2010 12:13:20 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>Server-side</category><category>WebGrid 6</category><category>Unbound</category><category>example</category><category>postback</category><category>new row</category><category>add row</category><description>&lt;p&gt;Hi, I have a screen with lots of controls and one list of items. This item list is shown in a WebGrid. I have two buttons to add and remove items into/from that list. When adding, another modal dialog pops up to select the correct item. When deleting, this is done by a checkbox column in the grid. And there's a save button on the form to save all data together back to the database. When a new row gets added to the WebGrid, this may not be saved to the database at that time, only later, if the user clicks on Save.&lt;/p&gt;
&lt;p&gt;I had to make bigger changes of this existing (working) page, because of bad design. Actually I almost had to rewrite it.&lt;/p&gt;
&lt;p&gt;In Page.Load I read in all data from the database (including the list of items) and store this in a local structure. I do not want to use session variables. Storing data in ViewState would be ok.&lt;/p&gt;
&lt;p&gt;What is the correct way of implementing something like this? It seems to be a standard problem. Is there a demo for this available somewhere? Should I make the WebGrid somehow unbound?&lt;/p&gt;
&lt;p&gt;In Page.Load I read in the data. And in grid.&lt;span style="font-size: 13px"&gt;InitializeDataSource I set the e.DataSource to the values from what I read in Page.Load earlier (by creating a table and assigning it). On Postback, I cannot read in the data again, because this would overwrite the current data. So after a Postback, the internal variable doesn't contain any data anymore. When clicking on Save, I save all fields back to the database. Is this design correct so far?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;But how would I implement the insert/delete of the rows to the WebGrid? For the Add button (&amp;lt;asp:Button&amp;gt;) I &lt;/span&gt;have an attribute like this: OnClientClick="ModalDialog(...&lt;/p&gt;
&lt;p&gt;In the click handler on the server side I read the ID of the selected item from a session variable (still bad design, but unchanged), which was set in the selection dialog, then get some more info from the DB and I think then I should add this data as a row to the WebGrid. Is that correct? How would I add this row? In the Button click event adding a row to the grid.RootTable? And even if this would work, how should I afterwards refresh the grid?&lt;/p&gt;
&lt;p&gt;Please help getting this designed correct with your control. We are using WebGrid version 6.0.7200.218. An example would be even better. But just help on the design is also ok. I think because this is a common problem, maybe there is already an example somewhere.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item></channel></rss>