Select an item of a combobox when using ItemTemplate

Posted by: pchanez on 10 September 2017, 11:27 am EST

  • Posted 10 September 2017, 11:27 am EST

    <P mce_keep="true">I'm trying to set the selected item of a combobox and when I'm using ItemTemplate, I do not manage to have it work </P>
    <P mce_keep="true">Here's what I'm doing :<BR>c1ComboBox.FindItemByValue(SelectedValue).Selected = true</P>
    <P mce_keep="true">If I put a break point during the rendering, the Text property is correct but in the browser it doesn't diplay. The very same code works fine when I'm not using the itemTemplate</P>
  • Replied 10 September 2017, 11:27 am EST

    <p> Hi pchanez,</p><p> </p><p>I checked this problem and found that this is a issue in C1ComboBox.  The input is created in CreateChildControls before your custom code is executed. I will fixed it in the new build. </p><p> </p><p>You can set the input value by yourself as a workaround.</p><p> Following is the code needed.<br></p><p>       C1ComboBoxItem item = C1ComboBox1.FindItemByValue("test");<br>        if (item != null)<br>        {<br>            item.Selected = true;<br>            // set input value before rendering.<br>            ((HtmlInputText)C1ComboBox1.Controls[0].Controls[0].Controls[0].Controls[0]).Value = item.Text;<br>        } <br></p><p> If you have any other problem please let me know.  </p><p> </p><p>Regards!</p><p> </p>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels