c# - set multiple values to combobox -
i have combobox multiselect option , want set multiple value codebehind , here store :
<ext:store id="storet" runat="server" pagesize="10"> <model> <ext:model id="model3" runat="server"> <fields> <ext:modelfield name="name" /> <ext:modelfield name="code" /> </fields> </ext:model> </model> </ext:store> <ext:combobox id="comboboxt" multiselect="true" storeid="storet" displayfield="name" valuefield="code"> </ext:combobox>
i want pass setvalues multiple codes selected @ same time .
please use combobox's selecteditems.
<%@ page language="c#" %> <script runat="server"> protected void page_load(object sender, eventargs e) { if (!x.isajaxrequest) { store store = this.combobox1.getstore(); store.datasource = new object[] { new object[] { "1", "item 1" }, new object[] { "2", "item 2" }, new object[] { "3", "item 3" }, new object[] { "4", "item 4" } }; } } protected void setvalues(object sender, directeventargs e) { this.combobox1.selecteditems.clear(); this.combobox1.selecteditems.add(new ext.net.listitem { value = "2" }); this.combobox1.selecteditems.add(new ext.net.listitem { value = "4" }); this.combobox1.updateselecteditems(); } </script> <!doctype html> <html> <head runat="server"> <title>ext.net v2 example</title> </head> <body> <form runat="server"> <ext:resourcemanager runat="server" /> <ext:button runat="server" text="set 2 , 4" ondirectclick="setvalues" /> <ext:combobox id="combobox1" runat="server" displayfield="text" valuefield="value" multiselect="true"> <store> <ext:store runat="server"> <model> <ext:model runat="server"> <fields> <ext:modelfield name="value" /> <ext:modelfield name="text" /> </fields> </ext:model> </model> <reader> <ext:arrayreader /> </reader> </ext:store> </store> <selecteditems> <ext:listitem value="1" /> <ext:listitem value="3" /> </selecteditems> </ext:combobox> </form> </body> </html>
Comments
Post a Comment