Question on DropDownList

R

rote

I have a DropDownList in a DetailView like so
<asp:TemplateField HeaderText="PCode">

<ItemTemplate>

</ItemTemplate>

<EditItemTemplate>

<asp:DropDownList ID="ddlCode" runat="server" BackColor="Pink"
DataSourceID="SqlDataSource2"

DataTextField="PCode" DataValueField="PCode" SelectedValue='<%#
Bind("PCode") %>'>

</asp:DropDownList>

</EditItemTemplate>

</asp:TemplateField>

The pcode is either 0,1,2
I need to change the DataTextField to a text string for example
if pcode is 0 then "boy"
if pcode is 1 then "girl"

Any ideas ?
Sure a function that returns a Datasource should be able to do it
But is there anyway i can do it in my aspx page?
 
N

nick chan

you could easily return from sql

select pcode, case when pcode=0 then 'boy' else when pcode=1 then
'girl' else 'others' end [sex] ..............

the set datatextfield to 'sex'
 
R

rote

Nick i know about that but i would be interested if they are other ways to
do it.

you could easily return from sql

select pcode, case when pcode=0 then 'boy' else when pcode=1 then
'girl' else 'others' end [sex] ..............

the set datatextfield to 'sex'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top