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 7511075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:26:26+00:00 2026-05-29T23:26:26+00:00

So I created a variable length list using the code shown here . When

  • 0

So I created a variable length list using the code shown here.

When I submit the form, the primary keys are reset to 0. In the HTML form, they are not zero but the actual values. How do I fix this?

The form

@using (Html.BeginCollectionItem("Kortingartikel")) { 

    @Html.HiddenFor(x => x.Artikelid)
    @Html.TextBoxFor(x => x.Artikelnaam)
    @Html.TextBoxFor(x => x.Prijs)</td>

}

The data

According to Chrome, this data is sent to the server:

Kortingartikel.index:ad56efb0-ab7f-4b37-9d9b-712d7c3e3543
Kortingartikel[ad56efb0-ab7f-4b37-9d9b-712d7c3e3543].Artikelid:5
Kortingartikel[ad56efb0-ab7f-4b37-9d9b-712d7c3e3543].Artikelnaam:test artikel een
Kortingartikel[ad56efb0-ab7f-4b37-9d9b-712d7c3e3543].Prijs:10,00
Kortingartikel.index:b9624d8f-38e6-4092-ba1b-d004d0443a43
Kortingartikel[b9624d8f-38e6-4092-ba1b-d004d0443a43].Artikelid:6
Kortingartikel[b9624d8f-38e6-4092-ba1b-d004d0443a43].Artikelnaam:test artikel twee
Kortingartikel[b9624d8f-38e6-4092-ba1b-d004d0443a43].Prijs:5,00

The Action

The data is sent to the following action:

public ActionResult Kortingartikel(IEnumerable<Kortingartikel> Kortingartikel)

The ‘Kortingartikel’ parameter has the following values:

[0]Artikelnaam:test artikel een
   Prijs: 10
   Artikelid: 0
[1]Artikelnaam:test artikel twee
   Prijs: 5
   Artikelid: 0

The property/field Artikelid
Artikelid is generated from a linq-to-sql dbml file. Here is the (autogenerated) code:

[global::System.Data.Linq.Mapping.ColumnAttribute(Name="artikelid", Storage="_artikelid", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]
    public long Artikelid
    {
        get
        {
            return this._artikelid;
        }
                    set
        {
            if ((this._artikelid != value))
            {
                this.OnArtikelidChanging(value);
                this.SendPropertyChanging();
                this._artikelid = value;
                this.SendPropertyChanged("Artikelid");
                this.OnArtikelidChanged();
            }
        }
    }
  • 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-29T23:26:28+00:00Added an answer on May 29, 2026 at 11:26 pm

    I suspect that the Artikelid on your Kortingartikel view model either doesn’t have a setter:

    public int Artikelid { get; } // Bad
    

    or it isn’t public:

    protected int Artikelid { get; set; } // Bad
    

    or it isn’t a property at all but it is a field:

    public int Artikelid; // Bad
    

    In all those cases the default model binder wan’t be able to set its value from the request. So make sure that this property is declared with public getter and setter on your view model:

    public int Artikelid { get; set; } // Good
    

    Also to avoid possible conflicts try renaming your action parameter:

    public ActionResult Kortingartikel(IEnumerable<Kortingartikel> model)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a simple ajax query which retrieves a variable-length list of values as
I have a list of variable length and want to create a checkbox (with
I've followed Steve Sanderson’s Editing a variable length list, ASP.NET MVC 2-style guide and
I'm trying to create a metaclass for the class I created here: ctypes variable
Once I've created a variable in the immediate window in C# (VS2008), is there
I am trying to created nested dictionary variable like the below, But I get
In the bash command line, I set a variable myPath=/home/user/dir . I created a
In my mvc 3 project I have a form which contains a list of
I'm trying to define variables within a loop. I'll drop the code here and
I've created a radio button menu list .. final CharSequence[] items = { 3

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.