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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:10:08+00:00 2026-05-12T09:10:08+00:00

Is it possible to bind such kind of property? public KeyValuePair<string, string> Stuff {

  • 0

Is it possible to bind such kind of property?

public KeyValuePair<string, string> Stuff { get; set; }

I’ve tried to use following code in the view, but it does not work:

<%=Html.Text("Stuff", Model.Stuff.Value)%>    
<%=Html.Hidden("Model.Stuff.Key", Model.Stuff.Key)%>
  • 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-12T09:10:09+00:00Added an answer on May 12, 2026 at 9:10 am

    KeyValuePair<K,V> is a structure, not a class, so each call to your Stuff property returns a copy of the original KeyValuePair. So, when you bind to Model.Stuff.Value and to Model.Stuff.Key, you are actually working on two different instances of KeyValuePair<K,V>, none of which is the one from your model. So when they are updated, it doesn’t update the Stuff property in your model… QED

    By the way, the Key and Value properties are read-only, so you can’t modify them : you have to replace the KeyValuePair instance

    The following workaround should work :

    Model :

    private KeyValuePair<string, string> _stuff;
    public KeyValuePair<string, string> Stuff
    {
        get { return _stuff; }
        set { _stuff = value; }
    }
    
    public string StuffKey
    {
        get { return _stuff.Key; }
        set { _stuff = new KeyValuePair<string, string>(value, _stuff.Value); }
    }
    
    public string StuffValue
    {
        get { return _stuff.Value; }
        set { _stuff = new KeyValuePair<string, string>(_stuff.Key, value); }
    }
    

    View :

    <%=Html.Text("Stuff", Model.StuffValue)%>    
    <%=Html.Hidden("Model.StuffKey", Model.StuffKey)%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:
Is it possible to bind to a property of a property? Here is what
Is it possible to add a dependency property to a ValueConverter and bind it
Consider the following code. public interface IFoo { } public class Bar { public
My problem can be easily defined with the following code: self.Bind(wx.EVT_MENU_OPEN, self.OnAbout) This will
I am unable to bind the selectedIndex public property of a spark DropDownList to
whether possible Bind complex list to DataSource a GridView with all members? such as:
Is it possible to bind the uri in the code below to a static
Is it possible to use PHP variables inside a prepared mySQL query, such as:
Is it possible to bind an additional resource string to another attribute within 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.