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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:05:29+00:00 2026-06-12T19:05:29+00:00

I have a dictionary property called Week: public IDictionary<DayOfWeek, Day> Week { get; private

  • 0

I have a dictionary property called Week:

public IDictionary<DayOfWeek, Day> Week { get; private set; }

And I’m trying to pass its values off to HiddenFor (Days)

@Html.HiddenFor(x => x.Week.Values)

It has to be a property of the Model so I can’t do x.Week.Values.ToList();

How would I go about passing the Dictionary Values to the Html.HiddenFor?

  • 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-12T19:05:30+00:00Added an answer on June 12, 2026 at 7:05 pm

    Well since your using HiddenFor, I’m going to assume that you need to rebind the values of the dictionary on form post. To bind a Dictionary to the view, your going to need to do something like this:

    @foreach (var key in Model.Week.Keys)
    {
        Html.DisplayFor(model=>model.Week[key]);
    }
    

    Each value in the dictionary will be given its own Hidden Input field, with the name attribute:
    name="Week.{key here}

    If, on the other hand, all you need to do is send the data in your model to the client so that you can do something with it in JavaScript, you might want to look at writing it to the page as JSON.

    <script type="text/javascript">
    @Html.Raw(Json.Encode(Model.Week))
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary public static IDictionary<string, IList<string>> checksCollection = new Dictionary<string, IList<string>>(); I
I have declared a property like so: private int? platypusLocalId; public int? PlatypusLocalId {
I have a property of my application in my sdef dictionary called busy <property
I have custom ContentControl called TabItem public class TabItem : ContentControl I have set
I have two Dictionary<string, Item> s. Item has a has a public property int
I have a UserControl with a property of type Dictionary, called HighlightedDates . The
I have a dictionary called fsdata at module level (like a global variable). The
I have a List<> of custom objects. This custom type has a property called
I have a model that contains a dictionary property. (this has been distilled from
I have an entity as under public class ContextElements { public string Property {

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.