IsmailS
IsmailS

Reputation: 10863

Display Pound currency sign (£) in a DataBound DropDownListItem

I need to show items like in below image.

alt text

I'm using this code to bind dropdownlist.

var options = (from option in _serviceOptions
                select new
                {
                  OptionId = option.OptionId,
                  OptionText = option.OptionText + " - " + option.Price + "£/month"

                }).ToList();

myDdl.DataSource = options;
myDdl.DataValueField = "OptionId";
myDdl.DataTextField = "OptionText";
myDdl.DataBind();

_serviceOptions is the resultset returned by calling stored procedure using L2S

The problem is, it is again encoding the & to & before rendering to the browser.

Upvotes: 0

Views: 837

Answers (1)

Lasse Espeholt
Lasse Espeholt

Reputation: 17792

Use the pound sign £ instead of £. It works here. The £ will be converted to £ which is equal to £.

var options = (from option in _serviceOptions
                select new
                {
                  OptionId = option.OptionId,
                  OptionText = option.OptionText + " - " + option.Price + "£/month"

                }).ToList();

Upvotes: 1

Related Questions