Binding two data columns to DataTextField

Discussion in 'ASP .Net' started by Angela, Jun 7, 2004.

  1. Angela

    Angela Guest

    Hi everyone,

    Is it possible to bind the DataTextField property to two values from a
    database.

    I would like the text from column("book") and the text from
    column("code") to appear in the DataTextField of a dropdown.

    If this is not possible is there are work around?


    Thanks


    Angela
     
    Angela, Jun 7, 2004
    #1
    1. Advertising

  2. Angela

    Ben Guest

    I'm sure there are many approaches to this, but I would do it inside
    OnItemDataBind. Create a datarowview, and process information as necessary.
    "Angela" <> wrote in message
    news:...
    > Hi everyone,
    >
    > Is it possible to bind the DataTextField property to two values from a
    > database.
    >
    > I would like the text from column("book") and the text from
    > column("code") to appear in the DataTextField of a dropdown.
    >
    > If this is not possible is there are work around?
    >
    >
    > Thanks
    >
    >
    > Angela
     
    Ben, Jun 7, 2004
    #2
    1. Advertising

  3. Angela

    David Wier Guest

    You can accomplish this easily by creating the item displayed in your SQL
    statement:
    Select book + ' ' + code as BookCode from (YourTableName)
    Then, use 'BookCode' as your DataTextField

    David Wier
    MCP, MVP ASP.NET, ASPInsider
    http://aspnet101.com
    http://aspexpress.com


    "Angela" <> wrote in message
    news:...
    > Hi everyone,
    >
    > Is it possible to bind the DataTextField property to two values from a
    > database.
    >
    > I would like the text from column("book") and the text from
    > column("code") to appear in the DataTextField of a dropdown.
    >
    > If this is not possible is there are work around?
    >
    >
    > Thanks
    >
    >
    > Angela
     
    David Wier, Jun 7, 2004
    #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. =?Utf-8?B?TWlrZQ==?=

    Setting DataTextField and DataValuedField on the fly?

    =?Utf-8?B?TWlrZQ==?=, Nov 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    340
    =?Utf-8?B?TWlrZQ==?=
    Nov 21, 2003
  2. Morten
    Replies:
    2
    Views:
    705
    Morten
    Dec 19, 2003
  3. Simon Harvey

    Binding two columns to a DropDownList

    Simon Harvey, Jun 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,578
    Rick Spiewak
    Jun 27, 2004
  4. nicholas
    Replies:
    5
    Views:
    15,730
    nicholas
    Dec 3, 2004
  5. quiggle

    Binding Two DataTable Columns to One DataGrid Column

    quiggle, Apr 2, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    183
    quiggle
    Apr 2, 2004
Loading...

Share This Page