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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -