﻿<?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 - Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</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>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Sun, 20 Apr 2014 21:38:10 GMT</pubDate><dc:creator>yudi</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Glad to hear that invoking Refresh() solve the problem.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Thu, 17 Apr 2014 13:11:06 GMT</pubDate><dc:creator>jarek@mantasolutions.com</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;Ok, no need for the example, calling W&lt;span style="background-color: rgb(255, 255, 255); color: rgb(31, 73, 125); font-family: 'lucida grande', 'lucida sans unicode', helvetica, arial, verdana, sans-serif; line-height: 19.5px; font-size: 10pt;"&gt;ebGrid1.ClientAction.Refresh() solved the problem.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color: rgb(255, 255, 255); color: rgb(31, 73, 125); font-family: 'lucida grande', 'lucida sans unicode', helvetica, arial, verdana, sans-serif; line-height: 19.5px; font-size: 10pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color: rgb(255, 255, 255); color: rgb(31, 73, 125); font-family: 'lucida grande', 'lucida sans unicode', helvetica, arial, verdana, sans-serif; line-height: 19.5px; font-size: 10pt;"&gt;Thank you very much!&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Wed, 16 Apr 2014 21:02:34 GMT</pubDate><dc:creator>yudi</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Could you please try to invoke WebGrid1.ClientAction.Refresh() after insert the new line in SQL Server? In the meantime, I’ll try to get a sample for you to be evaluated.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Tue, 15 Apr 2014 10:12:00 GMT</pubDate><dc:creator>jarek@mantasolutions.com</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;It is the .Data.ID() method &lt;span style="background-color: rgb(255, 252, 225); font-family: 'courier new', tahoma; font-size: 9pt;"&gt;rsSchedule.Data.ID()&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;But it might be easier for me to understand if we start from your example. &lt;/p&gt;
&lt;p&gt;Is your &lt;span style="background-color: rgb(255, 252, 225); font-family: 'courier new', tahoma; font-size: 9pt;"&gt;DoInsert&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;method called from the Webgrid&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: rgb(255, 252, 225); font-family: 'courier new', tahoma; font-size: 9pt;"&gt;AddRow&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&amp;nbsp;event? If so, after the method is called, what do you do with the returned OrderID parameter? How is it assigned to the webgrid?&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Tue, 15 Apr 2014 05:14:23 GMT</pubDate><dc:creator>yudi</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;When a new row is inserted through database adapter compatible provider, it does not return the new row’s identity by default. Thus, developers are required to write additional codes to programmatically obtain the new row’s identity.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Following C# code show how to retrieve new identity for ObjectDataSource control.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;[DataObjectMethodAttribute(DataObjectMethodType.Insert, true)]
public int DoInsert(ref Nullable OrderID, string CustomerID, Nullable EmployeeID, Nullable OrderDate,
Nullable RequiredDate, Nullable ShippedDate, Nullable ShipVia, Nullable Freight,
string ShipName, string ShipAddress, string ShipCity, string ShipRegion, string ShipPostalCode, string ShipCountry)
{
    this.Connection.Open(); // important    
    int affectedRows = this.Insert(CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight,
        ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry);
    int identity = this.SelectIdentityQuery();
    OrderID = identity; // pass the new identity into OrderID param    
    this.Connection.Close();
    return affectedRows;
}
public int SelectIdentityQuery()
{
    OleDbCommandcmd = new OleDbCommand("SELECT @@IDENTITY", this.Connection);
    int newID = (int)cmd.ExecuteScalar();
    return newID;
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;I’m not sure what function/method which equals to @@IDENTITY in your 3rd party object.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Mon, 14 Apr 2014 16:36:37 GMT</pubDate><dc:creator>jarek@mantasolutions.com</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;In fact it is a 3rd party object that does the database commands. &lt;/p&gt;&lt;p&gt;Here is the VB.NET code: &lt;/p&gt;&lt;pre&gt;Private Sub WebGrid1_AddRow(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.RowEventArgs) Handles WebGrid1.AddRow
    	Dim cells As New ISNet.WebUI.WebGrid.WebGridCellCollection
    	cells = e.Row.Cells
    	If cells.Item(0).Text &amp;lt;&amp;gt; "" Then		
    		   UpdateSchedule(cells)               				   
    	End If
End Sub&lt;/pre&gt;&lt;pre&gt;Private Sub UpdateSchedule(ByVal cells As ISNet.WebUI.WebGrid.WebGridCellCollection)
      
	Dim rsSchedule As TxAppFramework.Core.Metabase = New TxAppFramework.Core.Metabase(1000000110, TxSession)            
	rsSchedule.Data.Open()
	rsSchedule.Data.AddNew()
	rsSchedule.Data.Value("SERVICEMEMORANDUM_ID") = Context.Request("RecordID") 
	rsSchedule.Data.Value("TIME") = cells.Item(0).Text
	rsSchedule.Data.Value("V_PAP_CAR_TYPE_ID") = cells.Item(1).Value
	rsSchedule.Data.Value("ADDRESS") = UCase(cells.Item(2).Text)
	rsSchedule.Data.Value("DRIVER") = UCase(cells.Item(3).Text)
	rsSchedule.Data.Value("V_PAP_SCHED_TYPE_ID") = cells.Item(4).Value
	rsSchedule.Data.Value("NO_CARS") = cells.Item(5).Text
	rsSchedule.Data.Value("NOTES") = cells.Item(6).Text)	
	rsSchedule.Data.Update()
	
	'This is where the ID is read and set in the Grid cell
	cells.Item(8).Value = CStr(rsSchedule.Data.ID())  
	cells.Item(8).Text = CStr(rsSchedule.Data.ID())
	rsSchedule.Data.Close()
	rsSchedule = Nothing
End Sub&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;So the new identity is returned &amp;nbsp;by the "&lt;/span&gt;&lt;span style="background-color: rgb(255, 252, 225); font-family: 'courier new', tahoma; font-size: 9pt;"&gt;rsSchedule" object,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and is set as the value and text of the cell corresponding to the column that has the key field (index #8). Is there somewhere else it should be set?&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Mon, 14 Apr 2014 00:14:59 GMT</pubDate><dc:creator>yudi</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;I’d like to confirm whether you have executed SELECT @@identity after the insert command. It will allow you to save off the identity that was inserted.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Fri, 11 Apr 2014 11:01:29 GMT</pubDate><dc:creator>jarek@mantasolutions.com</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;Hi, thank you for the reply. &lt;/p&gt;&lt;p&gt;But no, it is there: &lt;/p&gt;&lt;pre&gt;&amp;lt;iswebgrid:WebGrid ID="WebGrid1" runat="server" DataMember="PAP_CAR_SCHEDULE" Width="776px" RenderingMode="HTML5" UseDefaultStyle="True"&amp;gt;
    &amp;lt;RootTable DataKeyField="CAR_SCHEDULE_ID" CaptionImage="order-details.gif" TableHeaderVis     ible="True" Caption="Car Schedule" DataMember="PAP_CAR_SCHEDULE"&amp;gt;&lt;/pre&gt;&lt;pre&gt;         ...
    &amp;lt;/RootTable&amp;gt;
    ...
&amp;lt;/iswebgrid:WebGrid&amp;gt;&lt;/pre&gt;
&lt;p&gt; &lt;span style="font-size: 10pt;"&gt;What I forgot to mention is that if I reload the page, the added row is there and can be edited just fine without giving errors. It happens only with rows that have just been added.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Thu, 10 Apr 2014 22:05:43 GMT</pubDate><dc:creator>yudi</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;I’m quite sure that you forgot to set the &lt;strong&gt;DataKeyField&lt;/strong&gt; property in &lt;strong&gt;RootTable&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;For example:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;ISWebGrid:WebGrid ID="WebGrid1" runat="server" ...&amp;gt;
    &amp;lt;RootTable Caption="Customers" DataKeyField="CustomerID" DataMember="Customers"&amp;gt;
        ...
    &amp;lt;/RootTable&amp;gt;
    &amp;lt;LayoutSettings AllowEdit="Yes"&amp;gt;
    &amp;lt;/LayoutSettings&amp;gt;
&amp;lt;/ISWebGrid:WebGrid&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Editing a row just after is was added</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Editing-a-row-just-after-is-was-added/</link><pubDate>Wed, 09 Apr 2014 11:59:02 GMT</pubDate><dc:creator>jarek@mantasolutions.com</dc:creator><category>WebGrid</category><category>AddRow</category><description>&lt;p&gt;With WebGrid 8, just after inserting a new row, if I try to edit it, when the update code is supposed to run, I get : &lt;/p&gt;
&lt;p&gt;Server Error in '/' Application.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Object reference not set to an instance of an object.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Source Error:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Stack Trace:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;[NullReferenceException: Object reference not set to an instance of an object.]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;   ISNet.WebUI.WebGrid.WebGridTable.IsKeyValueEqual(WebGridRow row, Object oKeyValues) &amp;#43;149&lt;/p&gt;
&lt;p&gt;   ..(DataView , XmlNode ) &amp;#43;2559&lt;/p&gt;
&lt;p&gt;   ..(DataView , String ) &amp;#43;1200&lt;/p&gt;
&lt;p&gt;   ..(DataView , String , String ) &amp;#43;1466&lt;/p&gt;
&lt;p&gt;   ..DataBind(Object , String ) &amp;#43;1584&lt;/p&gt;
&lt;p&gt;   ISNet.WebUI.WebGrid.WebGrid.() &amp;#43;183&lt;/p&gt;
&lt;p&gt;   ISNet.WebUI.ISNetControl.ControlRequestHandler(Object , EventArgs ) &amp;#43;303&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;[Exception: Object reference not set to an instance of an object.]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;   ISNet.WebUI.ISNetControl.ControlRequestHandler(Object , EventArgs ) &amp;#43;578&lt;/p&gt;
&lt;p&gt;   System.EventHandler.Invoke(Object sender, EventArgs e) &amp;#43;0&lt;/p&gt;
&lt;p&gt;   System.Web.UI.Control.OnPreRender(EventArgs e) &amp;#43;92&lt;/p&gt;
&lt;p&gt;   System.Web.UI.Control.PreRenderRecursiveInternal() &amp;#43;83&lt;/p&gt;
&lt;p&gt;   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) &amp;#43;974&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In the AddRow handler, I insert the new line in SQL Server. The Key is autogenerated by SQL Server. &lt;/p&gt;
&lt;p&gt;Then I read this new Key and set in the Value of the corresponding WebGridCell in the new row. &lt;/p&gt;
&lt;p&gt;Is there something else I need to do to correctly set the row's DataKeyField?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>