How to set the WebGrid's DropDownList field's Value?

1 reply. Last post: December 8, 2010 3:10 AM by Niven Prasetya
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Shawn AugustMember

What is the proper way to set the WebGrid's DropDownList field's value?

 

Currently, I am using the following method which uses the field's SetChanges method which allows me to set the text and value:

 

function WebGrid_SetDropDownListValue(field, text, value) 
{
    try 
    {
        // Set DropDownList's value
        if (field == null) { return; }
        field.SetChanges(text, value);
    }
    catch (ex) { ShowJSException(ex); }
}

This causes a few problems:

 

1) It will set the text regardless if the VALUE exists in the DropDownList control

2) When binded, the VALUE is displayed instead of the TEXT. If you click the DropDownList control, the text is displayed. For example, if the following DropDownList contains 1/A and 2/B, if the underlying value is set to "B", the "B" is visible in the WebGrid unless the user clicks the control and then "2" is displayed.

 

 

All times are GMT -5. The time now is 8:39 PM.
Previous Next