asp.net - Getting value from Dropdownlist in Checkboxlist in C# -
ok. did crazy. renders correct how selected value dropdown server-side using c#?
i tried getting dropdownlist code
checkboxlist.items[0].text.substring(checkboxlist.items[0].text.indexof("<select>"));
but have dropdown, how selected value it? edit 5/15/15 5:39pm est think if wrote code how creating this:
checkboxlist chkboxlst = new checkboxlist(); chkboxlst.items.add("grade"); chkboxlst.items.add("2"); chkboxlst.items.add("3"); chkboxlst.items[0].text += "<select id='letter' runat='server'> <option>a</option> <option>b</option> <option>c</option> </select>"
i creating dynamically server-side code.
<asp:checkboxlist id="checkboxlist1" runat="server"> <asp:listitem>grade <select id="letter" runat="server"> <option>a</option> <option>b</option> <option>c</option> </select> </asp:listitem> <asp:listitem>2</asp:listitem> <asp:listitem>3</asp:listitem> </asp:checkboxlist>
if see trying , know better way, suggestions welcome.
if trying accomplish selected value, change this
<select id="letter" runat="server"> <option>a</option> <option>b</option> <option>c</option> </select>
for this
<asp:dropdownlist id="letter" runat="server" > <asp:listitem text="a" value="a"></asp:listitem> <asp:listitem text="b" value="b"></asp:listitem> <asp:listitem text="c" value="c"></asp:listitem> </asp:dropdownlist>
and selected value this
string selectedvalue = letter.selectedvalue;
Comments
Post a Comment