Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1845
DataSource from List<string>
posted

In my MVC view, I'm trying to set the datasource to a list of strings from my viewmodel.  However, the combobox isn't rendering because I'm not setting the "ValueKey" and "TextKey" properties, because I don't have any, it's just a list of strings, there are no object properties to refer to.

Is there any way to get around this, or do I need to create a wrapper object with a single property like "Name"?  I realize I could use a Dictionary, but this smells.

Parents
  • 1845
    posted

    Nevermind, sorry!  My issue was unrelated, the combobox works perfectly fine by just assigning a list of strings to the datasource, no need to assign the "ValueKey" or "TextKey" properties.

    I tried deleting this post, but no such luck.

Reply Children
No Data