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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:25:56+00:00 2026-06-18T01:25:56+00:00

I try to bind an OrderedDictionary to a view but when the post method

  • 0

I try to bind an OrderedDictionary to a view but when the post method gets invoked the Dictionary is always empty.

Here is my code:

    [HttpGet]
    public ViewResult Edit(string username, string password)
    {
        Xml test = new Xml(@"c:\Users\pc\Desktop\xml - Copy.xml");
        XmlNode userNode = test.GetUserNodeByUsernameAndPassword(username, password);
        User user = new User();
        user.BindData(userNode);
        return View(user.user);
    }

    [HttpPost]
    public ViewResult Edit(OrderedDictionary attributes)
    {
        return View(attributes);
    }

And here is the view:

@using (Html.BeginForm("Edit", "Users")) {
@Html.ValidationSummary(true)

<fieldset>
    <legend>User</legend>

    <p>
        <input type="submit" value="Save" />
    </p>

    @{int counter = 0;}
    @{string name = "";}
    @foreach (DictionaryEntry attribute in Model)
    {
        { name = "[" + counter + "].key"; }
        <input type="hidden" name=@name value=@attribute.Key />
        @attribute.Key @Html.TextBoxFor(m => attribute.Value)
        counter++;
        <br />
    }
</fieldset>
}

And the result Html looks like this is:

<input type="hidden" value="Username" name="[0].key">
  Username
  <input id="attribute_Value" type="text" value="Anamana" name="attribute.Value">

So the content of the OrderedDictionary appears fine in the view but when I make a post back the binding isn’t working and the directory remains empty.

  • 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-18T01:25:57+00:00Added an answer on June 18, 2026 at 1:25 am

    Meantime I have found the solution.

    I can pass an OrderedDictionary to the view page.
    It process it by the following Razor code:

        @model System.Collections.Specialized.OrderedDictionary
        (...)
        @{int counter = 0;}
        @{string name = "";}
        @foreach (DictionaryEntry attribute in Model)
        {
            { name = "[" + counter + "].key"; }
            @Html.Hidden(name, attribute.Key)
            {name = "[" + counter + "].value";}
            @attribute.Key @Html.TextBox(name, attribute.Value)
            counter++;
            <br />
        }
    

    The result HTML‘s structure fits to the samples which is found in a book, the values from the dictionary appears fine on the page.

    After POST was invoked the POST handler function gets the modified values in a Dictionary.

        [HttpPost]
        public ViewResult Edit(Dictionary<string, string> attributes)
        {}
    

    I don’t know why but I can’t use OrderedDictionary here.

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

Sidebar

Related Questions

I try to bind XAML ListBoxItem using Code but doesn't seem work In my
I am try to bind the dropdowmlist using jquery. But is showing some error.
I try to bind a function to the click event on input button, but
i try to bind data to model with Html.EditorFor() helper and submit, but model
I have single grid page and try to bind data using Knockout but I
I discovered a problem in my code when I try to bind multiple sockets.
I try to bind a array from another array's change. but it not work.
I try bind FullScreenChange event, but it not work. Maybe i did something wrong?
I try to bind a NSString value into my SQL query but its not
When I try to bind in an MVC 3 view (using an @Html.DropDownList helper)

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.