TwitterBootstrapMvc icon indicating copy to clipboard operation
TwitterBootstrapMvc copied to clipboard

Problem with selectedValue for dropdownforenum

Open thechasboi opened this issue 11 years ago • 8 comments

this is my code. The drop down values are the string values and the text values are the string values of the enum. I am trying to set the selected value for the drop down and it will not work. Please advise. Thanks for the reply.

@form.FormGroup().DropDownListFromEnumFor(m => m.AppointingOfficialRole).OptionLabel("Select a role...").SelectedValue(Model.AppointingOfficialRole.ToString())

thechasboi avatar Jan 23 '14 20:01 thechasboi

the SelectedValue() extension is a bit misleading. Perhaps I should consider removing it. Try setting AppointingOfficialRole in the controller to the value you want and then just use helper like so:

@form.FormGroup().DropDownListFromEnumFor(m => m.AppointingOfficialRole).OptionLabel("Select a role...")

DmitryEfimenko avatar Jan 23 '14 23:01 DmitryEfimenko

Did you figure this one out?

DmitryEfimenko avatar Feb 02 '14 11:02 DmitryEfimenko

I used jquery. It seems there is a problem with your helper. I was also wondering if the enum had a description does it display that instead because it is more human readable? Thanks for the reply.

On Sun, Feb 2, 2014 at 6:26 AM, Dmitry A. Efimenko <[email protected]

wrote:

Did you figure this one out?

Reply to this email directly or view it on GitHubhttps://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/232#issuecomment-33898053 .

Charley George

Confidentiality Notice: This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that you are strictly prohibited from printing, storing, disseminating, distributing or copying this communication. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.

thechasboi avatar Feb 02 '14 17:02 thechasboi

I tested this. Setting selected value in the controller works for sure. I think it does work with [Description] attribute. I certainly remember doing something about it. Just give it a try.

DmitryEfimenko avatar Feb 02 '14 19:02 DmitryEfimenko

give an example because it is set from the db in the back end. What is this Description supposed to do? It does not seem like it is a method to set the drop down? Should we use this instead of selectedvalue for our other drop downs??? Thanks for the reply.

On Sun, Feb 2, 2014 at 2:10 PM, Dmitry A. Efimenko <[email protected]

wrote:

I tested this. Setting selected value in the controller works for sure. I think it does work with [Description] attribute. I certainly remember doing something about it. Just give it a try.

Reply to this email directly or view it on GitHubhttps://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/232#issuecomment-33909080 .

Charley George

Confidentiality Notice: This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that you are strictly prohibited from printing, storing, disseminating, distributing or copying this communication. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.

thechasboi avatar Feb 02 '14 19:02 thechasboi

Again I ask if I insert a Description attribute onto the enum will the drop down display that value? Thanks for the reply.

On Sun, Feb 2, 2014 at 2:10 PM, Dmitry A. Efimenko <[email protected]

wrote:

I tested this. Setting selected value in the controller works for sure. I think it does work with [Description] attribute. I certainly remember doing something about it. Just give it a try.

Reply to this email directly or view it on GitHubhttps://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/232#issuecomment-33909080 .

Charley George

Confidentiality Notice: This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that you are strictly prohibited from printing, storing, disseminating, distributing or copying this communication. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.

thechasboi avatar Feb 02 '14 19:02 thechasboi

Set up an empty project which reproduces issue and send it to me via email. I'll take a look.

Regarding [Description] attribute... give it a try. I think it will display that value.

DmitryEfimenko avatar Feb 02 '14 19:02 DmitryEfimenko

I used the Description and it worked - thanks

nat2k5us avatar May 15 '14 16:05 nat2k5us