Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3992310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:44:58+00:00 2026-05-20T06:44:58+00:00

I am learning ASP.NET MVC and Entity Framework Code First, LINQ by creating a

  • 0

I am learning ASP.NET MVC and Entity Framework Code First, LINQ by creating a simple Bug/Feature tracking system. I would like to mimic the Twitter interface by having the user submit a form above and having the submitted content appear below. I am not sure how to structure the strongly-typed view and the said model. I would like to merge my Create and Index views into a single view, the problem is the Create takes a single type Entry (Pylon.Models.Entry), while the Index takes IEnumerable of Entry (IEnumerable<Pylon.Models.Entry>). Below is my viewmodel class and Display view. I simply copied the code generated by scaffolding from the “Create” and “Index” views obviously mixing the different models causes run-time errors so the view is broken. My question is how do I restructure the view.

// Entry ViewModel
public class EntryViewModel
{
    public Entry Entry { get; set; }
    public IEnumerable<Entry> Entries { get; set; }
}

@* Display View *@

@model ?

@{
    ViewBag.Title = "Display";
}

<hr />

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Entry</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.OpenDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.OpenDate)
            @Html.ValidationMessageFor(model => model.OpenDate)
        </div>

        <div class="editor-label">
            Paradigm
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ParadigmId, ((IEnumerable<Pylon.Models.Paradigm>)ViewBag.PossibleParadigms).Select(option => new SelectListItem
        {
            Text = (option == null ? "None" : option.Name),
            Value = option.ParadigmId.ToString(),
            Selected = (Model != null) && (option.ParadigmId == Model.ParadigmId)
        }), "Choose...")
            @Html.ValidationMessageFor(model => model.ParadigmId)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<hr />

<table>
    <tr>
        <th></th>
        <th>
            Description
        </th>
        <th>
            OpenDate
        </th>
        <th>
            Type
        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @item.Description
        </td>
        <td>
            @String.Format("{0:d}", item.OpenDate)
        </td>
        <td>
            @(item.Paradigm == null ? "None" : item.Paradigm.Name)
        </td>
    </tr>
}

</table>

Any pointers or better yet tutorials/working code would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:44:59+00:00Added an answer on May 20, 2026 at 6:44 am

    Do the following changes.

    1. set @model EntryViewModel at top of the view.
    2. For create form, change model => model.Description to model => model.Entry.Description, so model is replaced with model.Entry
    3. For listing template, do the following change. @foreach (var item in Model.Entries )
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm look at learning a bit more ASP.Net MVC and Linq To Entity. I'm
I'm currently developing an app using ASP.NET MVC3 and Entity Framework 4.1 Code First
I'm learning ASP.NET MVC Framework, From some articles like this , it seems that
I'm a .NET Developer, primarily using c#, asp.net mvc, entity framework and programming for
I've starting programming on ASP.NET MVC Framework a year ago. Recently. I've learning Ruby
I am just learning ASP.Net's MVC framework and so my question is likely basic.
I am learning the ASP.NET MVC 3 Framework. In my layout page ( _Layout.cshtml
I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index
I'm just learning asp.net mvc and I'm trying to figure out how to move
Where can I find a good tutorial on learning ASP.NET MVC using VB.net 2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.