i'm trying bind sorted list(desc) radiobuttonlist control. isn't working. list gets bound in ascending order.
aspx:
<asp:radiobuttonlist id="rbl" runat="server" appenddatabounditems="true" datatextfield="optiontext" datavaluefield="value"> </asp:radiobuttonlist> c#:
list<options> lst = getlist(); rbl.datasource = (lst.findall(x => x.qid == 5)).orderbydescending(x => x.value).tolist(); rbl.databind(); public class option { private int _qid; public int qid { { return _qid; } set { _qid = value; } } private string _optiontext; public string optiontext { { return _optiontext; } set { _optiontext = value; } } private int? value; public int? value { { return _value; } set { _value = value; } } }
i'm pretty sure has using appenddatabounditems="true". if want append new items consider adding them
foreach(var item in (lst.findall(x => x.qid == 5)).orderbydescending(x => x.value)) { lst.items.insert(0, new listitem(item.optiontext, item.qid)); } not beauty, @ least you're in control. otherwise consider creating datatable , use datasource.
note: found related problem here
Comments
Post a Comment