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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:06:25+00:00 2026-06-11T04:06:25+00:00

I am following this tutorial. Can anyone please explain to me how I can

  • 0

I am following this tutorial. Can anyone please explain to me how I can make the textboxes bind back to the Dictionary? Right now all that happens is the data is being displayed in the textboxes – but if I change the textboxes, how do I bind back to the object?. What am I missing? Below is my code:

 <input type="text" name="@Model.ExpirimentToRemove[i].Value.Title" value="@Model.ExpirimentToRemove[i].Value.Title"/>
 <input type="text" name="@Model.ExpirimentToRemove[i].Value.PreviewDescription" value="@Model.ExpirimentToRemove[i].Value.PreviewDescription"/>
 <input type="text" name="@Model.ExpirimentToRemove[i].Value.FullDescription" value="@Model.ExpirimentToRemove[i].Value.FullDescription"/>
  • 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-06-11T04:06:27+00:00Added an answer on June 11, 2026 at 4:06 am

    The name of your text input field is wrong. You have put the value of the model instead of naming it appropriately as explained in the Hanselman’s blog post.

    So let’s assume that you have some view model:

    public class ItemViewModel
    {
        public string Title { get; set; }
        public string PreviewDescription { get; set; }
        public string FullDescription { get; set; }
    }
    

    and a main view model containing the dictionary:

    public class MyViewModel
    {
        public Dictionary<string, ItemViewModel> ExpirimentToRemove { get; set; }
    }
    

    and your POST controller action takes this view model as parameter:

    [HttpPost]
    public ActionResult Remove(MyViewModel model)
    {
        ...
    }
    

    In order to correctly bind to this view model you could have the following:

    @model MyViewModel
    @using (Html.BeginForm())
    {
        @for (var i = 0; i < Model.ExpirimentToRemove.Count; i++)
        {
            <div>
                @Html.TextBox(
                    "ExpirimentToRemove[" + i + "].Key", 
                    Model.ExpirimentToRemove[i].Key
                )
                @Html.TextBox(
                    "ExpirimentToRemove[" + i + "].Value.Title", 
                    Model.ExpirimentToRemove[i].Value.Title
                )
                @Html.TextBox(
                    "ExpirimentToRemove[" + i + "].Value.PreviewDescription", 
                    Model.ExpirimentToRemove[i].Value.PreviewDescription
                )
                @Html.TextBox(
                    "ExpirimentToRemove[" + i + "].Value.FullDescription", 
                    Model.ExpirimentToRemove[i].Value.FullDescription
                )
            </div>
        }
    
        <p><button type="submit">OK</button></p>
    }
    

    In this example the key of the dictionary is a simple string value but you could also use a complex type.

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

Sidebar

Related Questions

Can anyone please help. Im following a tutorial on drawing primitives from the MSDN
This question was asked before, but it wasn't answered properly. Can someone please explain
Can anyone please tell me what r we actually meaning by the following statement
Following this tutorial and running into trouble. [TestMethod] [ExpectedException(typeof(Exception))] public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() { var
Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
i'm following this tutorial: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide and downloading my own source of mod_wsgi. The problem
I was following this tutorial , but for the life of me I cant
I was following this tutorial: http://www.vogella.com/articles/AndroidLocationAPI/article.html --> Paragraph 6.0 Problem: My emulator runs perfectly
I'm following this tutorial for twitter4j: http://www.javacodegeeks.com/2011/10/java-twitter-client-with-twitter4j.html and I've gotten almost everything right. All
I'm following this tutorial: http://developer.android.com/training/basics/firstapp/running-app.html#Emulator In it there is a simple code for a

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.