MVC :: Model Not Found When Creating A View?
Sep 3, 2010Trying to create a strongly typed view but the model "that is a class" is not listed in the "View data class" dropdown?
View 3 RepliesTrying to create a strongly typed view but the model "that is a class" is not listed in the "View data class" dropdown?
View 3 RepliesEDIT: This question is vague and will likely be of little use to anyone. I am awarding internet monies to the gentleman below whom "helped" me.Sorry that the title is a little vague. I am still new to asp mvc & EF. Here is my issue. I have a DB somewhat like this.
Employee
- ID
- Name
- Address
EmployeeJob
- EmployeeID
- JobID
- StartDate
JobTypes
- ID
- JobName
I want a create form that will show all the Employee fields as well as a list of JobTypes for the users to be able to select. Then I will post the results back to the controller and update the DB. I have started looking into custom viewmodels, but am still unsure of exactly how to put that together and get it to work.
I have been reading about different model for development
model view control mvc
model view presenter MVP
Model view view model MVVM
i belive MVC has two big Advantage over webform 1) TDD 2) More control on HTML
MVP is bit variation in mvc model. rapid development as well as 1) TDD 2) More control on HTML (correct me if i m wrong) see the below link
[URL]
I've been used to decorating data model classes with data annotation attributes, but the purist in me baulks slightly at including purely presentational attributes such as display format here. I am, however, quite happy to keep validation centric attributes here. One good reason I have to continue keeping all annotations etc. in the data model is that my view model aggregates data model classes, e.g.
my ViewModelBase.DetailItem<TEntity> property in the view model is just a reference to an entity class in my data model. If I wanted to move presentational annotations to the view model, I would have to quite radically revise my design to one where I duplicate data model properties in my view model and use an object mapping tool to populate view model objects based on data model objects.
[code]....
Say I got a domain model as follows: (and my repository expect an instance of this object)
[Code]....
And a view model (which my views are based on)
[Code]....
At the moment I got it like this and have my controller action manually create a new Person object from the PersonModel object before passing it on to the repository, which does not feel right.
So I tried to have PersonModel inherit from Person and pass that to the repository (also tried casting the PersonModel to a Person object first), but that don't work out.
What's the right way to have PersonModel automatically cast to Person? I want to keep this logic as my current structure allow me to keep things really loosely coupled, with the repository layer not having a clue how it's being used.
I have an entity object as model input in my view. Not sure if it's the best approach, but I use the object references to get values from a related object.Let's say I've got a car entity and a manufacturer entity.Here's how it would look in my view
[Code]....
I've get a nullreferenceexception where the car entitity does not have a reference towards manufacturer. I'd like to output a " " if no manufacturer exists.
've created a Search partial view and it works, except for my view model. What i mean is, the partial view sends a string to my ActionResult Method, but only a string, that is not related to the view model that the partial view is built in. If i tell my ActionResult method to receive the view model in which the partial view is built in, it always tells me that i have null values. Here's my code This is my partial view:
[Code]....
Now here is my Model in my MoviesSearch view model:
[Code]....
Now the actual MoviesSearchViewModel
[Code]....
Inside my Search controller i have this
[Code]....
And then i have this:
one thing that has been puzzling me since learning MVC2 is the following case scenario: I have a view which contains two latest news lists, a login form and a signup form. Every example I found on Views and View Models so far has a one-to-one example such as a simple login form etc. But how do I create a model that provides the properties and validation for a login and signup form and manages the data for the news lists. can I pass multiple models in the strongly typed view? When I created one model the form validation would fail as it expects all fields - login and signup to be filled. I am missing some advanced examples or information.
View 2 Repliesmaking my first steps with asp.net mvc and I actually create a (very) small website.I have 1 controller : TasksController1 view : Tasks/Index.aspx1 Partial View : Tasks/AvailableSorting.ascx In my controller I have 2 methods :
[Code]....
In my Tasks/Index.aspx, I add my partial view (<% Html.RenderPartial("AvaliableSorting"); %>)
That sounds simple. But, It just doesn't work : the Index return a list of Task and the parial view (should) return a list of string.The index.aspx works perfectly, but the partial view doesn't get the right model ! he gets the model of the Index page (list of Task).
I would like to add a partial view to my view page
The view page contain a mode name "<IEnumerable<JvTake1.Models.VortN>>
And the partial view contain a model name "<IEnumerable<JvTake1.Models.VideoL>>"
So, theoretically I think they were suppose to work together but no Can any one guide me how to make it happen?
I've got problem with my app .
I've got such classes (this is some kind of tree structure):
[Code]....
[Code]....
in Index() action i've got this piece of code
[Code]....
[Code]....
I am totally a new bee in asp.net mvc. Let me now explain my issue. I have a strongly typed view which inherits from a view model Document. I want to have a partial view in that view itself. My code for this purpose is :
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<HexsolveMVC.Models.Document>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
DetailsDocumentTemplate
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<div>
<div>
2.4</div>
<div>
Published</div>
<h1>
Document Title: <span>
<%=Model.DocTitle %></span><span><a href="#">[ Edit ]</a></span></h1>
<ul>
<li>
<label>
<span>*</span>Created Date:</label>
<span>
<%= Model.DocCreatedDate%></span></li>
<li>
<label>
Status:</label>
<span>.................................
I have a view that is not strongly typed. However I have in this view a partial view that is strongly typed.How do I do I pass the model to this strongly typed view?I tried something like
public ActionResult Test()
{
MyData = new Data();
MyData.One = 1;
return View("Test",MyData)
}
In my TestView
<% Html.RenderPartial("PartialView",Model); %>
This give me a stackoverflow exception. So I am not sure how to pass it on. Of course I don't want to make the test view strongly typed if possible as what happens if I had like 10 strongly typed partial views in that view I would need like some sort of wrapper.
This is a simplified example of what I need. Imagine a person table with several different club tables. Every person can belong to any number of clubs, but must belong to at least one club. The association would be a 1 to zero or one between the person table and each of the club tables.I've created the databases, then the entity model. The associations are all 1 to many, which isn't what I want.
Is there a way to modify the database so that the model is created correctly? I'm still building the project, making lots of changes, and I've had problems with updating the model, so I keep recreating it. Setting up the database correctly would be preferable.I'm trying to follow the quickstart here: [URL]but I'm using the SQL Management Studio designer, and I can't find how to fix the associations I add.
I've been reading about using or not using foreign keys in the model, but it's only confused me more. Can someone help me understand this? I'm starting to write code with what I have, and I'm running into problems. I'm about to start using joins, which means I'm trying to use a hammer instead of a saw because I don't know how to use my saw. I'd rather understand my tools and use them the right way!
When I am creating Strongly Typed View I get lots of Classes in View Data Drop down. Classes like Automapper, ninject, Interface..., latebound... Due this its very hard to find my project classes. Is there any way to restrict dropdown to only display my project classes?
View 1 RepliesWhen using the "add view" dialog in vwd is there a common practice for presenting any primary key fields as readonly to the user in the view?
By default it appears the user could change the key field value (as it is presented in a textbox) and overwrite data for that record for which the key was accidentally changed to.
Do we have to store the original record's key and then make the key presented as a label and then on the update subtitute the original key value back in for the record? Or is there something simpler?
I am trying to create a relation between 2 of my model classes. I have separated my Model classes to be in their own project "Domain Model" and the application exists in the "WebUI" project.
I have 2 models.... SupportIssues and Users....
SupportIssues has a column UserID which is also a primary key in the Users table.
I want to create a relationship where one user can have many support issues.
I just can figure out how to do this?
Here is a snippet of my supportIssue.cs class:
[Code]....
How can i link UserID to my User.cs class?
Is it anything to do with the [Associate] tag?
I'm trying to build a link to an external website using some properties of my model class in my view page, e.g. I want it to render as something like -[URL]where post-id would be pulled from the model (I'm using a strongly typed view model here - I can't use ViewData as there's a list of items being pulled back all of which need seperate links).I tried doing < a href="<% model.PermaLink(); %>">, where PermaLink is just some string, however the value doesn't get picked up.If I try < a href="<%= model.PermaLink %>">, I get an error - CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid argumentsIs there any way to do this? I tried adding the runat="server" attribute, however this just linked to my local site and controller/model actions.
View 2 RepliesI'm trying to customize correct displaying of dropdownlists so information shown in comboboxes is relevant to the kind of user logged on (maintaining referential integrity at data level)
e.g.: I have a user already logged on and depending on his profile I'd like to display to this user only the portion of the database that he would be allowed to see. That would mean that he might have acces to an specific subset of data, e.g.: businesstype = "3", loging level = "2", etc.
Is there a way of creating an Ado.Net Entity Data Model filtered on a Session variables as to maintain proper referential integrity at data level?
This program used to work when I had VWD 2005 express and SQLSERVER 2005 express. Then we upgraded to VWD 2008 express and SQLSERVER 2008 express. Now it fails Error running adodb Provider cannot be found. It may not be properly installed. 3706 To clarify; I used to run variations of the following to create small offline cub files that I could email to remote Users:-
PROVIDER=MSOLAP;
DATASOURCE=C:TESTAMRunAdodbTestMyCube.CUB;
SOURCE_DSN=AMCubeData;
CREATECUBE=CREATE CUBE AMCubeData(
DIMENSION [Channels],
LEVEL [ALL Channels] TYPE ALL,
LEVEL [Channel Group Name],
LEVEL [Channelname],
MEASURE [Sales Val]
Function Sum
Format 'Standard');
INSERTINTO=INSERT INTO AMCubeData(
[Channels].[Channel Group Name],
[Channels].[Channelname],
MEASURES.[Sales Val])
SELECT [ChannelGroupName] AS Col1,
[channelname] AS Col2,
[Sales Val] AS Col23
FROM dbo_qryCubeDataExtra
;
in a VB6 program that ran them in a ADODB connection something like :-
Dim MyCnn As ADODB.Connection
On Error GoTo Err_ErrorHappened
Set MyCnn = New ADODB.Connection
MyCnn.Open (MyAdodbcmd)
I can't believe I'm having so much trouble finding this information. I'm endeavouring to learn about creating model classes with Linq to SQL. By default VS2010 wants to use SQL Express, but our organisation has several database servers for development so I'd rather use one of those. PLEASE can somebody tell me how I can configure VS2010 to do that, as all I get is 'A network-related or instance-specific error occurred while establishing a connection to SQL Server ... Verify that the instance name is correct'. Yeah, thanks Microsoft. Actually telling me how to verify the instance name would be a really good move here.
View 1 RepliesI created a MVC project. Added a area "SampleArea". Then added a controller "Log" in the area. Generate a view for "Index" in the log controller.
Modified the global.asax to this
routes.MapRoute(
"Default", // Route name
"{area}/{controller}/{action}/{id}", // URL with parameters
new { area = "SampleArea", controller = "Log", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I also modified
ontext.MapRoute(
"SampleArea_default",
"SampleArea/{controller}/{action}/{id}",
new { controller="Log", action = "Index", id = UrlParameter.Optional }
);
Pressed F5 and it is giving err "The view 'Index' or its master was not found". How do i fix it?
The sample can be downloaded from here [URL]
I have created a class UserDetailsModel.cs in my folder model. I have populated a selectedList in the model class.
I have create a view which is both strongly-typed and partial and the view data class is the abc.cs
I have the following code in the view
[Code]....
However, i`m getting the error of
[Code]....
[Code]....
I have 3 table:
student: ID,name,family
course: ID,name
studentCourse: ID,studentID,CourseID
and I want to show student name and family and a dropdownlist of courses in a create view.
which model should I use to create the view?I used viewModel but I don't know how to show this dropdownlist?
can I do something like this to get the Mode.check value in my view..
<script type="text/javascript">
var check = <%(Model.Check); %>;
$(document).ready(function () {
[code]...