MVC :: 2 NerdDinner - Data No Longer Saves After Adding ViewModel

Sep 3, 2010

I am creating the NerdDinner application via the Professional ASP.NET MVC 2 book, and once I got to the ViewModel part (pages 88-91), I noticed none of my data was saving any longer. I discovered several errors and areas of confusion in these pages of the book, which I will list now.

Page 88: When it says to add the DinnerFormViewModel class, it doesn't say what folder to add it to. On page 89, the Inherits example (NerdDinner.Controllers.DinnerFormViewModel) implies it was added to the Controllers folder, but if that were so, the code on page 88 would need to use Models.Dinner instead of just Dinner. No big deal; just put it in Models and change the Inherit statement on page 89 to use NerdDinner.Models.DinnerFormViewModel.

Page 89: At the bottom of the page is some wrong code. Since the properties of Dinner are now one level deeper, all references to m.Title, m.Country, etc, need to be m.Dinner.Title, m.Dinner.Country, etc. The statements above the code are also incorrect ("Notice... we are not changing the names of the input elements... the form elements will still be named...") -- the form elements will actually change from "Title", "Country", etc to "Dinner_Title", "Dinner_Country", etc.

Page 90 (Code Snippet 1-53): This was the one that broke the data saving. Now that the form elements have prefixes, the TryUpdateModel(dinner) needs to pass a prefix, like TryUpdateModel(dinner, "Dinner"). This will append "Dinner_" to the element names so that they can be found on the form.

View 3 Replies

Similar Messages:

MVC :: Get Same Nerddinner.Entities As Mvc Sample Nerddinner Using ADO Entity Framework

Oct 10, 2010

DbClick the code behind file of NerdDiner.edmx,It reads "This code was generated from a template." on the top comment lines. I generate my own .edmx file automatically with VS2010, just found that the .designer.cs file didnt contains Objectset,Methods as nerddinner does IDK which template hanselman used to generate this .edmx files´╝îdont tell me he wrote it all by himself! Shoud .edmx and its code behind file be generated automaticlly without hard-coding?

View 4 Replies

MVC :: ViewModel And Adding To / Accessing List

Apr 12, 2010

I am trying to create a view that would contain a set of fields that tie to an AgencyAddress object, an add button, and under those fields, a list of AgencyAddress that would show addresses that were added. My view works, and the fields are properly bound, however I can't seem to get the list to maintain previously added addresses.

What happens, is that every time the Add button is pressed, the List is re-created (or VS yells at me to create a new instance) and only contains one record. I'm sure I'm missing something simple, but I can't figure out how to pass the list back and forth and be able to add to it. Two weeks on my own is where I draw the line! My ViewModel:


My Create controller action (HTTP Get) is here:


And finally, my HTTP Post Create action:


The loop in the view that should show addresses:


View 3 Replies

Web Forms :: Enter Key No Longer Submits After Adding LoginImageUrl To Asp:LoginStatus?

Jan 7, 2010

I have a login page inside of a master page. On the left-hand side of the master page in side a navigation menu, there is a search box with a button that is set to be the default submit button via code when text has been entered into the search text box.


ABOVE the search box is a ASP:LoginStatus control that when the user clicks "Login" it takes you to a login.aspx page which contains a ASP:Login control inside the same master page. Without setting the LoginImageUrl and LogoutImageUrl properties of the ASP:LoginStatus, the login/logout appears as text. And the enter button works when a user enters text into the search box (submits info to search service and takes user to search results) OR if the user enters their user name and password into the Login control and hits enter (logs in and redirects user based upon role). Everything works fine. Once I set the loginImageUrl and LogoutImageUrl properties of the ASP:LoginStatus though, the enter key no longer submits anything. It will just postback the page.

I'm guessing that adding an image to those properties cause the loginstatus to take the default behavior of a button. How do I prevent it from breaking the behavior of the enter key on everything else?

View 1 Replies

NHibernate Saves Without Commit() Or Flush()?

May 18, 2010

I have a strange situation.An ASP.NET button click event causes an object in memory to be updated. The object was loaded from NHibernate via Refresh() during Page_Load, but at no time during the entire page life cycle is Commit() or Flush() called.At some point after the page's OnUnload step, the object and any changes made to it are automatically persisted to the database. I cannot see when or where or why this occurs.

View 2 Replies

VS 2008 Looking For Map Program That Saves Jpeg?

Sep 24, 2010

I have an ASP.NET website where we are generating pdf's and web pages using crystal reports. One of the requirements we have is for in the pdf's to have a map of NY state with markers on it that are placed based on GIS Coordinates. For the web page we can do this easily with google maps. if there are any third party map generating solutions that can do this? We currently use map info and google maps, but I dont think either are capable of doing this?

View 3 Replies

Create Web Page - Saves As Pdf File On Clicking

Jul 19, 2010

I am wondering if it is possible (for as little money as possible) to create a web page that when a user clicks the submit button saves a file as a PDF. it is going to be used as a purchase order creator on a webpage. I have seen a few tutorials around but they seem to use software that requires purchasing a license.

View 4 Replies

VS 2008 - Uppercase Textbox Saves As Lowercase?

Feb 1, 2010

I'm using this style text-transform:uppercase to convert to uppercase in a textbox. Works fine, but it saves as lowercase.

View 3 Replies

DataSource Controls :: DataSet Saves DB Name In DbObjectName?

Feb 19, 2010

I am having an issue with the DataSet saving the name of the Database that the table or query is ran from in the .xsd inside the DbObjectName even though it is being called from the connectionstring in the web.config file. I have the following line in the connectionstring setting the initial catalog to the DB name:


the line adds the DB name (dbName_Sandbox.dbo.MySQLScript) automatically, how do I stop this and only have dbo.MySQLScript?

Example of someone else having same issue, but they just did a mass find replace, I don't want to do this every time I have to create a DataSet then deploy to the production server.


View 1 Replies

Need A ViewModel To Take 1-to-many-data To The View?

Feb 23, 2011

This is probably basic stuff, but I can't find the clear answer anywhere..Lets say I'm doing an MVC (3) application with Entity Framework (EF4), and I have these three classes:

public class Foo
public int FooID


View 1 Replies

MVC :: NerdDinner And Logo Link?

Sep 17, 2010

I have uploaded the nerddinner sample to "". When a mouse is on menu tab such as "Find a host" then the link is shown at the bottom of Internet explorer as "" with the contoller name "Dinner". When the mouse is on the main logo which is on top and left, the link shown as "". So it direct me to "" instead of ""

When can I change it? I have tried change the "start url" from the application property, but it did not work.

View 1 Replies

MVC :: Change Needed To NerdDinner Mvc Example?

Mar 15, 2010

As I am working thru the NerdDinner MVC example. I found that after implementing step 6 that edits to a dinner were no longer saved. After some investigation I found that I needed to add the ValueProvider to the UpdateModel function call in Edit (HttpPost) example. My updated code is below.


1. Was this code change really necessary?

2. Is there a better way to do it?

Modified Code:


View 5 Replies

Forms Data Controls :: Gridview Will No Longer Show The Data - Datagrid Datasource = Null

Feb 25, 2011

I am familiar with populating a gridview with data. I am able to bind the Data pulled from the database into the gridview

gridview.DataSource = myDataTable;

If I write the following code, teh gridview will no longer show the data

gridview.DataSource = null;

My question is , I want to make the same thing with a user control that contain a gridview. when I use the user control in an aspx page, I am able to populate it with data, but when I try to make this code, the Datasource does not show, instead, I see .DV. So I tried this code but then , I do not see DataSource property instead I see DV (DataView), when I put .DV = null, I get an error message that the object is not in existed. any idea how to clear the user control gridview from its data.

View 2 Replies

MVC :: Nerddinner Using The Database From SQL EXPRESS Server

Mar 26, 2010

I have problem when I am working on the NerdDinner tutorial. If I create local database (in the project local) then it is working OK, but if I added connection with the database already existed in the SQL EXPRESS 2005 (using Data Connections -> Add Connection; from the Server Explored in the VS 2008) then I got GPF. Does anyone know how to use the database for server instead of local project?

View 3 Replies

MVC :: Nerddinner LogOn And Authentication Method?

Mar 14, 2011

i created a mvc project and looked to account controller LogOn action method. methood defined as bottom.



View 3 Replies

MVC :: Passing ViewModel With Data From View To Controller

Dec 13, 2010

I am trying to pass a view model of mine, which has multiple list in it, to my view. Then in my view i need to edit the different list. Then on my post i need to save the edits. Although, when i pass my viewmodel back to my post, it is empty! Can somebody explain what i am doing wrong? Controller

here is my View




View 2 Replies

MVC :: Scenarios Where Data Validation Is Done In The Viewmodel Not The Model?

Jun 8, 2010

point out an example or tutorial online that shows where data validation is done in the viewmodelas against the model? i saw a number of posts where that method is recommended..i dont really agree with it but i would like to see how it would work out..

View 2 Replies

Mvc Nerddinner Question Linq To Entities Join?

May 13, 2010

I am working on a website similar to nerddinner. Is it possible to perform similar join
using Linq to entities what is done with linq to sql in nerddinner.I am posting the codes below.

public IQueryable<Dinner> FindByLocation(float latitude, float longitude) {
var dinners = from dinner in FindUpcomingDinners()
join i in db.NearestDinners(latitude, longitude)


View 1 Replies

MVC :: NerdDinner: Map / Ends Up On The Exact Same Coordinates On The Map Regardless Of The Address?

Nov 21, 2010

I started a website based on the NerdDinner source code, everything worked fine (more or less) but whenever I post an event, it ends up on the exact same coordinates on the map regardless of the address (Somewhere in the Gulf of Guinea!)

No idea what to do: I didn't alter the map code at all!

View 2 Replies

MVC :: Funy Error While Trying To Imitate Nerddinner Datarepository?

Jan 23, 2010

I created a repository, just the way it was done in nerddinner but i cnt seem to get any intellisense on the word "db'..the code is below;


View 2 Replies

MVC :: To Put The Data Annotation Attributes - On The Viewmodel Classes Or On The Model?

Mar 20, 2010

I am using a model but as I want to have clean views I use the viewmodel approach which is like a downsized model which I map in my controller actions before sending to the view or getting it back in a HttpPost attributed action.

My question is: where to put the data annotation attributes. On the viewmodel classes or on the model? If I get it clearly the viewmodel annotations are used for the client side generation of validation right?

Do does that mean I have to put data annotations everywhere on both model and viewmodel?

View 11 Replies

Forms Data Controls :: FindControl No Longer Works In Datalist?

Feb 9, 2010


now, I added information to the <headertemplate><table><tr><td>headers</td></tr></table></headertemplate>

and my label in the <itemtemplate><asp:Label id="Label1" runat="server"></asp:label></itemtemplate>

and now when I run my same code, I get [object reference not set to an instance of an object]

what gives? It was working until I added a header template.

View 2 Replies

Forms Data Controls :: IDataReader No Longer Can Be Bound To Repeater .NET 4.0?

Nov 19, 2010

I had a web application that was binding a IDataReader to a repeater control. I converted the project from 3.5(2.0) to 4.0 and then I received the error:

An invalid data source is being used for rptData. A valid data source must implement either IListSource or IEnumerable.

So, I used a datatable instead and the binding worked. So it seems that they have removed this functionality with .NET 4.0.

View 4 Replies

MVC :: NerdDinner Sample - How Does Delete Work - How To Control Deletes

Jun 7, 2010

I am still at the elementary stages of Linq To Sql and Entities usage. I started practicing MVC developement by following the NerdDinner tutorial here at, and I back myself up with fully developed NerdDinner sample (1.0 -- still on VS2008). I am also at the first half of the NerdDinner tutorial (I think -- maybe I'm further along) - so far I have gotten up to the Delete View. In the fully developed sample I noted that it uses ascx file (which I guess I will find out if the tutorial also will use
ascx files down the road). My sample app, which I am developing from the tutorial, seems to work OK so far. My issue is that I am not clear how the Delete mechanism works. In the DinnerRepository.cs I have this code (from the tutorial):


It looks like a dinner object is being passed to these mechanisms and the delete occurs based on a row ID value. But what if I wanted to delete multiple rows - say where ID between 15 and 20 - how to go about this? I was looking for a Delete statement but am not finding it either in what I have developed so far from my tutorial sample or from the fully developed sample. How can I control Deletes in MVC?

View 1 Replies

MVC :: Nerddinner Repository Dinner Edit Fails To Save?

Dec 10, 2010

I'm trying to use the Nerddinner as a model to built my own project. I'm using the repository method but I cannot fiqure out why the Edit does not save to the database. I tested in the Nerddinner and it failed to save as well. Is this not functional in Nerdinner or could it be due to me using VS 2010 express?

I also started using MVC3 so I thought that could be the problem. I did some testing and was able to get my Edit to update to the database if I have the controller access the database instead of the repository.

Here's the relevant code from NerdDinner:


View 35 Replies

Copyrights 2005-15, All rights reserved