<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET Dynamic Data</title><link>http://forums.asp.net/1145.aspx</link><description>Discussions regarding the new scaffolding framework in ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3107239.aspx</link><pubDate>Tue, 21 Apr 2009 10:54:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3107239</guid><dc:creator>zorgit</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3107239.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3107239</wfw:commentRss><description>&lt;p&gt;Does exactly what it says on the tin!&lt;/p&gt;</description></item><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3107208.aspx</link><pubDate>Tue, 21 Apr 2009 10:44:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3107208</guid><dc:creator>sjnaughton</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3107208.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3107208</wfw:commentRss><description>&lt;p&gt;Sorry I was forgetting (I can&amp;#39;t converet VB=C# in my head) you need to use the LinqDataSource&amp;#39;s Inserted event see:&amp;nbsp;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;Protected Sub&lt;/span&gt; DetailsDataSource_Inserted(&lt;span class="kwd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwd"&gt;As Object&lt;/span&gt;, &lt;span class="kwd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwd"&gt;As&lt;/span&gt; System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) &lt;span class="kwd"&gt;Handles&lt;/span&gt; DetailsDataSource.Inserted
    &lt;span class="kwd"&gt;If&lt;/span&gt; ((e.Exception &lt;span class="kwd"&gt;Is Nothing&lt;/span&gt;) _
                &lt;span class="kwd"&gt;OrElse&lt;/span&gt; e.ExceptionHandled) &lt;span class="kwd"&gt;Then&lt;/span&gt;
        Response.Redirect(table.GetActionPath(PageAction.Details, e.Result))
    &lt;span class="kwd"&gt;End If
End Sub&lt;/span&gt;
&lt;/pre&gt;Hope this is it &lt;img src="http://forums.asp.net/emoticons/emotion-2.gif" alt="Big Smile" /&gt;</description></item><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3107185.aspx</link><pubDate>Tue, 21 Apr 2009 10:35:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3107185</guid><dc:creator>zorgit</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3107185.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3107185</wfw:commentRss><description>&lt;p&gt;Steve,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure how I would reference it, but I have found that in DetailsDataSource_Inserted the eventargs contains a Result object which is the returned value, which can be cast to the object type and contains the returned ID.&lt;/p&gt;
&lt;p&gt;Thanks for your help!&lt;/p&gt;</description></item><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3107163.aspx</link><pubDate>Tue, 21 Apr 2009 10:24:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3107163</guid><dc:creator>sjnaughton</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3107163.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3107163</wfw:commentRss><description>&lt;p&gt;You should now get an entity with the PK value in it now in the DetailsView_ItemInserted method.&lt;/p&gt;</description></item><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3107139.aspx</link><pubDate>Tue, 21 Apr 2009 10:12:40 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3107139</guid><dc:creator>zorgit</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3107139.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3107139</wfw:commentRss><description>&lt;p&gt;Steve,&lt;/p&gt;
&lt;p&gt;Thanks for the reply, the article was very helpful, I can now use the stored procedure to insert the information with the returned value added to the passed in instance. However it is still not clear how to access this from the DetailsView_ItemInserted method.&lt;/p&gt;
&lt;p&gt;In the DataContextClass the generated code is:&lt;/p&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Private&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Sub&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; InsertArticle(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;ByVal&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; obj &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; Article)&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp; Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; p1 &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Nullable(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Of&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Integer&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;) = obj.ArticleId&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp; Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.fgp_InsertArticle(p1, obj.HTMLPageName, obj.Title, obj.Summary, obj.PageContent)&lt;br /&gt;&amp;nbsp; obj.ArticleId = p1.GetValueOrDefault&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;End&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Sub&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this is called correctly when I&amp;nbsp;click the Insert button on the detailsview object and the correct Id is returned to the InsertArticle routine&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;but in the DetailsView_ItemInserted how to I get access to this value- looping through the values collection of the&amp;nbsp;&lt;font size="2"&gt;DetailsViewCommandEventArgs displays all the values of the fields as entered by the user but not this returned value. Even if I add a field for the ArticleID to the DetailsView it does not get the value from the InsertArticle routine. Generally how would I access the instance of the DataContextClass used by the DetailsView to perform this insert?&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font size="2"&gt;Thanks&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>Re: How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3105315.aspx</link><pubDate>Mon, 20 Apr 2009 18:05:37 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3105315</guid><dc:creator>sjnaughton</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3105315.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3105315</wfw:commentRss><description>&lt;p&gt;See &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/08/23/linq-to-sql-part-7-updating-our-database-using-stored-procedures.aspx"&gt;LINQ to SQL (Part 7 - Updating our Database using Stored Procedures)&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/bb386946.aspx"&gt;Stored Procedures (LINQ to SQL)&lt;/a&gt;&lt;/p&gt;</description></item><item><title>How to override default insert method of Details View in Dynamic Data</title><link>http://forums.asp.net/thread/3104355.aspx</link><pubDate>Mon, 20 Apr 2009 11:55:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3104355</guid><dc:creator>zorgit</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3104355.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3104355</wfw:commentRss><description>&lt;p&gt;I would like to change the default method of inserting data to make it use a stored procedure, plus I would like to get a return value from this stored procedure returned to the calling code.&lt;/p&gt;
&lt;p&gt;Scenario is that on insert the default behaviour is to go to the list view, but I would like to get from the insert the autogenerated primary key and use this to re-direct to a different form showing the newly inserted record.&lt;/p&gt;
&lt;p&gt;I see that I can create a partial class for the DataContext class and then create my own InsertTable method which will be called on the insert action, but this is a sub so it is not clear how to return a value to the Insert.aspx code behind class for processing.&lt;/p&gt;
&lt;p&gt;I can override the DetailsView ItemInserting method, but to use this I would need to set the cancel property to true to prevent double insertion, and then the validation behaviour does not work.&lt;/p&gt;
&lt;p&gt;So how would this be done?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>