Question on DropDownList

  • Thread starter Thread starter rote
  • Start date Start date
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?
 
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'
 
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'
 
Back
Top