﻿<?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 - Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</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/WebGrid/Unbound-WebGrid-example-common-design/</link><pubDate>Wed, 09 Jun 2010 04:37:39 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 Glenn,&lt;/p&gt;
&lt;p&gt;Thanks for your new sample.&lt;/p&gt;
&lt;p&gt;We use the WebGrid version 6.0.7200.218 (as mentioned in initial question) and framework version 3.0.5000.705 (ActiveReports.Exporting.dll version 5.0.7200.3).&lt;/p&gt;
&lt;p&gt;Yes, there are several problems with the sample, like that both Update buttons don't work, the crash, etc. but I can ignore all this, as long as this happens only in the sample and not in our real project. If you would still like to investigate, I'm happy to help. (I don't think it's related to this minor version difference.)&lt;/p&gt;
&lt;p&gt;Ok, so with your sample I could add the row on the server side. I had to change a little bit, because casting to a DataSet didn't work. Here is what finally helped me (VB.NET):&lt;/p&gt;&lt;span style="font-size: 13px"&gt;&lt;pre&gt;Dim dt As DataTable = CType(grid.DataSource, DataTable)
Dim values() As Object = {1, "init", "value", 0.0, 0.0}
dt.Rows.Add(values)
grid.RebindDataSource()
&lt;/pre&gt;&lt;p&gt;I'm not finished yet, but I assume there will be no other problems related to this. If there are, I will reply again or open a new thread (if not directly related).&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;Eric&lt;/p&gt;&lt;/span&gt;</description></item><item><title>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</link><pubDate>Wed, 09 Jun 2010 00:06:21 GMT</pubDate><dc:creator>Glayaar</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;I have updated the sample so there is a button to add and update row in server side, the basic idea is still the same. Sample attached.&lt;/p&gt;&lt;p&gt;The database operation, for simplicity is using data adapter, since internally WebGrid will mark the updated, added, or deleted data row with the correct row state (Modified, Added, or deleted ), so calling the data adapter update method will process the modified, deleted, and added data based on the data adapter update, insert, or delete command. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In my sample, during AddRow and UpdateRow event handler I return false in order to prevent the WebGrid internal event handler to execute because we are not doing any database operation.&lt;/p&gt;
&lt;p&gt;Regarding the error you mention during Add Row buton click, I have not encounter such issue in my environment, have you used the latest WebGrid 6 and WebUI Framework 3? The latest build is 219 and 752 respectively. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I can't comment on whether the design is bad or good. However, I have provide an alternative method if you willing to try.   &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</link><pubDate>Tue, 08 Jun 2010 11:49:22 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;One more info on this: The old application worked - at least regarding the unbound data handling. I think it's a bad design, but decide yourself. If I cannot find a better solution quickly, I'll will use this also. Here it is:&lt;/p&gt;
&lt;p&gt;In Page_Load the data for the grid is loaded from the database. The full DataSet is stored in a Session variable. Then calls to grid.ClearCachedDataSource() grid.DataSource=(from session), then grid.DataBind(). The event grid_InitializeDataSource is not implemented.&lt;/p&gt;
&lt;p&gt;When clicking the Add button, the modal popup, opened by JavaScript in the OnClientClick event selects the data and stores the ID in another session variable. In the button handler event (server side) the DataSet from the session is being read. A new DataRow is added and again grid.ClearCachedDataSource, grid.DataSource=, grid.DataBind is set.&lt;/p&gt;
&lt;p&gt;I think it is bad to store the full dataset in the session (and also the ID of the selection dialog). If not other possible, at least ViewState for the DataSet should be used. But I think this data belongs to the WebGrid, and I should not cache this data in my code again.&lt;/p&gt;
&lt;p&gt;Eric&lt;/p&gt;</description></item><item><title>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</link><pubDate>Tue, 08 Jun 2010 10:37:23 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;Hello Glenn,&lt;/p&gt;
&lt;p&gt;Thanks for your answer. BulkUpdate sounds like letting WebGrid do all the Update, but all at once. I looked through your sample and the BulkUpdate description, but I'm still missing something. Also, I'd like to mention the differences:&lt;/p&gt;
&lt;p&gt;- The final Save to the database is done by me (server side) through a single call to a stored procedure (passing XML with all the grid data). In your sample you are somehow using a DataAdapter instead.&lt;/p&gt;
&lt;p&gt;- I'm not sure what I'm missing, but when I click the button "Add Row" your sample crashes. The JavaScript GridAddRow runs successfully through, but then, within WebGrid code, somewhere it crashes. What happens is that a window pops up showing an unhandled exception (NullReferenceException in WebGrid.DataBinding). I can only click on Copy or Close.&lt;/p&gt;
&lt;p&gt;- What's the exact purpose of the AddRow/UpdateRow handler setting e.ReturnValue=false?&lt;/p&gt;
&lt;p&gt;- The main difference to what I need is that you add the data by the JavaScript GridAddRow. I have to add the data on the server side, because I need to get the data from the database first. I don't know how to add a row to the WebGrid on the server side without letting WebGrid go through a InitializeDataSouce call.&lt;/p&gt;
&lt;p&gt;Any hints on this?&lt;/p&gt;
&lt;p&gt;Eric&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</link><pubDate>Mon, 07 Jun 2010 22:49:24 GMT</pubDate><dc:creator>Glayaar</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>What you are trying to achieve is called bulk update in WebGrid 6 and we already have an article regarding this feature in this&amp;nbsp;&lt;a href="http://support.intersoftpt.com/docs/webgrid/5.0.7200/Perform Bulk Update on a Button Click event.html" target="_blank"&gt;page&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;If you would like to programatically add and edit WebGrid row, we already provided a sample on Client_ProgrammaticEdit.aspx.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;I have attached a simple sample that demonstrate both of this functionality. Database operation will only be executed when [Save] button is clicked. The button [Add Row] will add a new row with static data, while the [Update Row] button will modify the ContactName and ContactTitle of the first row in the Grid. The sample is using northwind.mdb database which has already been provided in WebGrid sample.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;If you are willing to upgrade to WebGrid 7, the feature has been natively supported using the batch update feature. We have also provided batch update feature in WebGrid 7 provided sample.&lt;/div&gt;</description></item><item><title>Unbound WebGrid example wanted / Help on common design</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Unbound-WebGrid-example-common-design/</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>