I have a product name eg, "Ham &
Egg" and I to want show in the dropdownlist as "Ham & Egg" but I don't seem to be able to display it with this code here:
drpProd.DataSource = Productlib.Product_SelectAll();
drpProd.DataTextField = Server.HtmlDecode("ProdName");
drpProd.DataValueField = "ProdID";
drpProd.DataBind();
drpProd.Items.Insert(0, new ListItem("------Select One Please------"));
Even after I used Server.HtmlDecode("ProdName"), it still displays as "Ham &
Egg". How should I go about it? Thanks a lot and in advance.
Chetan Ranpariya, thanks for giving me a hint and thanks guys I have managed to solve it and here is the code:
SqlDataReader dr = Productlib.Product_SelectAll()
while (dr.Read())
{
ListItem listItem = new ListItem();
listItem.Text = HttpUtility.HtmlDecode(dr["ProdName"].ToString());
listItem.Value = dr["ProdID"].ToString();
drpProd.Items.Add(listItem);
}
drpProd.Items.Insert(0, new ListItem("------Select One Please------"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.