Question on DropDownList

Discussion in 'ASP .Net' started by rote, Feb 29, 2008.

  1. rote

    rote Guest

    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?
     
    rote, Feb 29, 2008
    #1
    1. Advertising

  2. rote

    nick chan Guest

    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'

    On Feb 29, 2:37 pm, "rote" <> wrote:
    > 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?
     
    nick chan, Feb 29, 2008
    #2
    1. Advertising

  3. rote

    rote Guest

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

    "nick chan" <> wrote in message
    news:...
    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'

    On Feb 29, 2:37 pm, "rote" <> wrote:
    > 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?
     
    rote, Mar 2, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,676
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,271
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,899
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,338
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    12,174
    shauns1
    Nov 1, 2006
Loading...

Share This Page