Thursday, September 27, 2012

Data Formatting for DataTextFormatString field for dropdownlist in asp.net



int ID = convert.ToInt32(ddl.SelectedItem.Value)
tblEntities Entities = new tblEntities();
ddl.DataSource = Entities.widget.Where(p => p.MID == ID).ToList();
ddl.DataTextField = "ID";
ddl.DataValueField = "ID";        
ddl.DataTextFormatString = "Widget - " + "{0}"; <------ Formatted Text
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("--Select--", "-1"));

No comments:

Post a Comment

Comments

Search

Custom Search
Protected by Copyscape Plagiarism Software