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

  • SEARCH
  • Home
  • 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 500737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:07:05+00:00 2026-05-13T06:07:05+00:00

My classes are a DataModel, which uses ID as its PK, and a Map,

  • 0

My classes are a DataModel, which uses ID as its PK, and a Map, which also has ID as a PK. Map has a FK to DataModel (DataModelID).

I have a partial view that I use from my DataModel list view as follows:

 <% foreach (var map in Model.Map)
    { %>
 <% Html.RenderPartial("MapEdit", map); %>
 <% } %>

My MapEdit partial view looks like:

Before: <%= Html.Encode(Model.ID) %>

<% using (Html.BeginForm()) {%>
    <label for="ID">ID:</label>
    <%= Html.TextBox("ID", Model.ID) %>
    <%= Html.ValidationMessage("ID", "*") %>
<% } %>

When I run this, I would expect to see ([ ] represent a textbox):

Before: 4
ID: [ 4 ]

Before: 5
ID: [ 5 ]

etc...

Where each number is the actual ID from the record. What I actually get is:

Before: 4
ID: [ 10 ]

Before: 5
ID: [ 10 ]

10 in this case happens to be the ID from the DataModel! I have no idea where this is coming from, because stepping thru the code shows that Model.ID has the correct value – at some point however it’s getting replaced.

Can anyone explain this?

  • 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-13T06:07:05+00:00Added an answer on May 13, 2026 at 6:07 am

    If Model.Map is null, Model will be passed to the partial view instead. That’s how partial views work.

    Also, model values are copied to the ModelStateDictionary, which can have only one key called ID. This makes sense since any form you submit would use the keys as the form field name.

    ModelStateDictionary values supercede model values so that the form can be re-rendered with invalid user input when necessary. Usually, model and model state values are the same on initial (non-error) display. But this isn’t the same if you have duplicate keys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 303k
  • Answers 303k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Scott Gu talks about Dynamic linq here May 13, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer JEdit seems to be very scriptable with Java, BeanShell, Jython… May 13, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer Try to use WCF Service to connect to your DLL.I… May 13, 2026 at 8:38 pm

Related Questions

I have a Java server application and a Flex client application. For my data
I designed a data model which is represented by an XSD scheme. The data
Well, not literally, of course, but: I'm new to Flex and I'm trying to
I have a question on the best way of exposing an asynchronous remote interface.
I am developing a desktop application with a MainForm that's grown rather large. There

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.