<rss version="2.0" 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"><channel><title>Part 5: Edit Forms and Templating</title><link>http://www.asp.net</link><pubDate>Fri, 05 Oct 2012 04:01:39 GMT</pubDate><generator>umbraco</generator><description>Comments for Part 5: Edit Forms and Templating</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/27629" rel="self" type="application/rss+xml" /><item><title>Comment Posted by lizimu706</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Thu, 23 Dec 2010 20:40:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011294</guid><description><![CDATA[ <p>very good tutorial,very helpful THX</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/lizimu706.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by sasiatia</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 04 Jan 2011 05:51:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011404</guid><description><![CDATA[ <p>nice ... everything is working as expected ..</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/sasiatia.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by chuck6478</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Thu, 27 Jan 2011 20:14:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011806</guid><description><![CDATA[ <p>Excellent tutorial series</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/chuck6478.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by greg pang</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Wed, 27 Apr 2011 02:20:56 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012997</guid><description><![CDATA[ <p>As you can see from the action method code, three parameters are being used to create this object:</p><p></p><p>The list of items the dropdown will be displaying. Note that this isn’t just a string - we’re passing a list of Genres.</p><p></p><p>The next parameter being passed to the SelectList is the Selected Value. This how the SelectList knows how to pre-select an item in the list. This will be easier to understand when we look at the Edit form, which is pretty similar.</p><p></p><p>/** above line must be wrong ! in the edit action code, there are 4 parameters, </p><p>            ViewBag.GenreId = new SelectList(db.Genres, &quot;GenreId&quot;, &quot;Name&quot;, album.GenreId);  </p><p></p><p>the last parameter is the selected value, let the DropDownList know how to pre-select item. **/</p><p></p><p>The final parameter is the property to be displayed. In this case, this is indicating that the Genre.Name property is what will be shown to the user.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/greg%20pang.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by peacockp</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 20 May 2011 10:57:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013229</guid><description><![CDATA[ <p>Anyone noticed that on the Details page the Genre and Artist data is empty. </p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/peacockp.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by peacockp</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 20 May 2011 11:37:23 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013230</guid><description><![CDATA[ <p>Nevermind, after completing Step 6 this is cleared up.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/peacockp.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by darkrider23</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Thu, 02 Jun 2011 17:37:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013373</guid><description><![CDATA[ <p>@Greg, I believe the second parameter is the &quot;value&quot;</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/darkrider23.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Elsaa</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Sun, 05 Jun 2011 00:58:31 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013410</guid><description><![CDATA[ <p>After modifying the scaffolding view, I am not able to display the list of the albums with links to Edit, Details, and Delete. Can anyone help me out?</p><p>Thanks</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Elsaa.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by bkinc</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 02 Aug 2011 14:08:30 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013891</guid><description><![CDATA[ <p>When setting up an MVC 3 application, the foreign keys that should allow drop down lists to select an item do not get rendered as drop downs, but as static inputs.  This can be resolved by creating a custom display and view for that field.</p><p>We will need to start by creating a custom partial view that will live in “~/Views/Shared/DisplayTemplates/UserGuid.cshtml”, and “~/Views/Shared/EditTemplates/UserGuid.cshtml”.  The code for one is located below:</p><p>@model Guid</p><p></p><p>@{ </p><p>	incMvcSite.Models.MvcSiteDB db = new incMvcSite.Models.MvcSiteDB();</p><p>	incMvcSite.Models.SecUser usr = db.SecUsers.Single(u =&gt; u.Guid == Model);</p><p>}</p><p>@usr.Display</p><p></p><p>This is a display for template that will look up the item in the referenced table and display it.  We also need an edit for template as follows:</p><p></p><p>@model Guid</p><p>@{ </p><p>	incMvcSite.Models.MvcSiteDB db = new incMvcSite.Models.MvcSiteDB();</p><p>	SelectList items = new SelectList(db.SecUsers.OrderBy(i =&gt; i.Display).ToList(), &quot;Guid&quot;, &quot;Display&quot;, Model);</p><p>}</p><p>@Html.DropDownList(&quot;&quot;, items)</p><p></p><p>The edit for template is implemented as a drop down list.  Originally, we has used static HTML code, but the problem will appear of implementing a “prefix”.  Static HTML code does get handled by HTML helpers, so it’s recommended that you use the HTML.DropDownList().</p><p>To force the MVC framework to use the new Display and Edit for templates, we need to annote our model item an add the following line:</p><p></p><p>[UIHint(&quot;UserGuid&quot;)]</p><p></p><p>This will cause MVC to use the Display and Edit templates named “UserGuid”, which are just partial views.</p><p><a rel="nofollow" href="http://www.internetworkconsulting.net" target="_blank">www.internetworkconsulting.net</a></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/bkinc.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by samarmir</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Thu, 06 Oct 2011 15:21:26 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014348</guid><description><![CDATA[ <p>Thanks for another excellent part</p><p></p><p>Mohammad</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/samarmir.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by KAZAMAI_NaruTo</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Sat, 08 Oct 2011 15:54:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014369</guid><description><![CDATA[ <p>I had a &quot;jQuery is not defineded.&quot; error when after &quot;Create New&quot; Link or &quot;Edit&quot; Link on list page.  It is necessary to place &quot;jQuery-1.4.4.min.js&quot; to &quot;Scripts&quot; folder, isn&#39;t it? </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/KAZAMAI_NaruTo.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ms_gigabyte</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 25 Nov 2011 06:52:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014690</guid><description><![CDATA[ <p>I am getting Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries. error while trying to update a record. Any idea how to fix this. Using following code </p><p></p><p>        &lt;HttpPost()&gt;</p><p>        Function Edit(album As Album) As ActionResult</p><p></p><p>            If ModelState.IsValid Then</p><p>                _db.Entry(Album).State = EntityState.Modified</p><p>                _db.SaveChanges()</p><p>                Return RedirectToAction(&quot;Index&quot;)</p><p>            End If</p><p></p><p>            ViewBag.GenreId = New SelectList(_db.Genres, &quot;GenreId&quot;, &quot;Name&quot;, Album.GenreId)</p><p>            ViewBag.ArtistId = New SelectList(_db.Artists, &quot;ArtistId&quot;, &quot;Name&quot;, Album.ArtistId)</p><p>            Return View(Album)</p><p>        End Function</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ms_gigabyte.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ricka6</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Wed, 30 Nov 2011 22:08:28 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014722</guid><description><![CDATA[ <p></p><p>ms_gigabyte : On November 25, 2011 06:52 AM said: </p><p></p><p></p><p></p><p></p><p></p><p>ms_gigabyte : I am getting Store update, insert, or delete statement affected an unexpected number of rows (0).</p><p>You can fix this by adding the following line to the Edit.cshtml file</p><p>        @Html.HiddenFor(model =&gt; model.AlbumId)</p><p>The reason for that error is the AlbumId is not posted back, so it defaults to zero (and there is 0 AlbumId in the DB).</p><p> </p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ricka6.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by qbressler</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 07 Feb 2012 20:32:54 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014795</guid><description><![CDATA[ <p>Hmm...I can delete records fine. However, when I try to update or create an entry I get the following error:</p><p></p><p>Null value for non-nullable member. Member: &#39;Artist&#39;.</p><p></p><p>It hangs on this line of code:</p><p> db.SaveChanges();</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/qbressler.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tertl3</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 02 Mar 2012 12:10:12 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015002</guid><description><![CDATA[ <p>I am not getting the truncating to work?  My text just moves down the next line.  What is going on here?  any help please.  Oh, and great article.  I&#39;m going through a little at a time</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tertl3.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by captain60s</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Sun, 11 Mar 2012 22:57:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015092</guid><description><![CDATA[ <p>Perhaps someone can help me? I run the application and browse to /StoreManager (where a list is displayed), no problem.  I then click the Edit link (or the create link) and receive the following error.  </p><p>Microsoft JScript runtime error: &#39;jQuery&#39; is undefined.</p><p></p><p>Note other functions are ok, Delete, Details</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/captain60s.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by captain60s</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Mon, 12 Mar 2012 14:54:32 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015100</guid><description><![CDATA[ <p>I took KAZAMAI_NaruTo&#39;s (above comment) suggestion to move &quot;jQuery-1.4.4.min.js&quot; to &quot;Scripts&quot; folder. Sorry, but no joy.  </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/captain60s.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by kanu273</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 01 May 2012 10:07:09 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015441</guid><description><![CDATA[ <p>There must be a way to download these tutorials..</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/kanu273.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tmorton</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Wed, 02 May 2012 17:19:38 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015444</guid><description><![CDATA[ <p>The newest version of this project, and corresponding downloadable tutorial, can be found at <a rel="nofollow" href="http://mvcmusicstore.codeplex.com/releases/view/64379." target="_blank">mvcmusicstore.codeplex.com/</a></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tmorton.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by rguarnieri</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 15 Jun 2012 14:47:51 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015776</guid><description><![CDATA[ <p>Hi, A have an error Creating the StoreManagerController:</p><p></p><p>Unable to retrieve metadata for MvcMusicStore.Models.Album. Could not load file or assembly, file///C:Users\XXXX\AppData\Local\Temp\rpnn41bq.dll&#39; or one of its dependencies. Operation is not supported. (Exception from HRESUL: 0x80131515</p><p></p><p>Any idea? many thanks!</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/rguarnieri.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by superandi</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Sat, 16 Jun 2012 02:42:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015784</guid><description><![CDATA[ <p>Doesnt break anything.. I just noticed that the truncate does not limit the strings to 25 chars, since the &quot;...&quot; is also appended. One should take length-3, but then one would also have to check for length being at least 3. Makes sense since with the &quot;...&quot; you always have min length 3.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/superandi.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jonf</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 28 Aug 2012 17:18:45 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016333</guid><description><![CDATA[ <p>I&#39;m getting the same problem as @ms_gigabite and I tried to add the code like @ricka6 posted but the results are the same.  The Album ID isn&#39;t gettting passed back to the controller from the view.  Others mentioned step 6 but I completed that too and the reslults are the same.  The album object comes back without the AlbumID, Artist Name or Genre Name, everything else comes back valid.   Also I&#39;m not seeing an easy/clear/intuitive way to debug the queries from the Entity Framework.  Has anyone else experieced this?  </p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/jonf.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jonf</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Tue, 28 Aug 2012 18:10:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016334</guid><description><![CDATA[ <p>UPDATE: </p><p>I found this; </p><p>[Bind(Exclude = &quot;AlbumId&quot;)]</p><p> in the Album.cs file and if I comment this out the edit works.  It&#39;s not real clear why this is there however. </p><p>There is also a line that says;</p><p> [ScaffoldColumn(false)]</p><p>Would this prevent the generated view from getting a line for the AlbumId?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/jonf.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by fsulistio</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Thu, 27 Sep 2012 16:14:38 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016538</guid><description><![CDATA[ <p>IF you got this error: Microsoft JScript runtime error: &#39;jQuery&#39; is undefined.</p><p>You need to add this to the View file.  Especially for Create and Edit StoreManager.</p><p></p><p>&lt;script src=&quot;<a rel="nofollow" href="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js" target="_blank">ajax.aspnetcdn.com/</a>&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/fsulistio.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by hungnt.onmobi.vn</title><link>http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5</link><pubDate>Fri, 05 Oct 2012 04:01:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016576</guid><description><![CDATA[ <p>ViewBag.ArtistId = new SelectList(db.Artists, &quot;ArtistId&quot;, &quot;Name&quot;);</p><p></p><p>This is an error. At that time, MusicStoreEntities does not have Artists property.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/hungnt.onmobi.vn.jpg?forceidenticon=false&amp;dt=635050074600000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>