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
865
Optgroup in WebDropDown
posted

Is it possible to include optgroup-like items in a WebDropDown control?  For example:

 

<optgroup label="Operating System">

<option value="Mac">Mac</option>

<option value="PC">PC</option>

</optgroup>

Parents
  • 24671
    Suggested Answer
    posted

    Hi,

    Currently this is not possible out of the box, but using the <Templates> collection, this is easily achievable.

    For the items that you would like to be of type <optgroup>, define the following template:

    <ig:Template ID="optgroupTemplate">

    <optgroup label="<%# DataBinder.Eval(Container.DataItem, "<label property>")%>">

    </ig:Template>

    Then for the other items define:

    <Template ID="optionTemplate">

    <option value="<%# DataBinder.Eval(Container.DataItem, "<value property>")%>">

    </Template>

    Then in code behind (or in markup) you can associate the actual DropDown items with the templates, so you get the correct rendering and structure.

    Please let me know if you need a more detailed example (you can also contact our Development Support team for this).

    Thank you,

    Angel 

Reply Children
No Data