c# - LINQ to DropDownList with Server.HtmlDecode -
i have code uses linq populate dropdownlist:
var usercategories = dataaccesslayer.context.categories .where(c => c.username == httpcontext.current.user.identity.name) .select(c => new { c.id, c.category }) .orderby(c => c.category); categorydropdownlist.datasource = usercategories; categorydropdownlist.datavaluefield = "id"; categorydropdownlist.datatextfield = "category"; categorydropdownlist.databind();
where put server.htmldecode category?
first, want htmlencode, not htmldecode. here's example:
foreach (var category in usercategories) { categorydropdownlist.items.add(new listitem(server.htmlencode(category.category), category.id.tostring())); }
Comments
Post a Comment