Multiple datatextfield values in checkboxlist

Discussion in 'ASP .Net Web Controls' started by Andrew Todd, Aug 13, 2003.

  1. Andrew Todd

    Andrew Todd Guest

    Hi

    I have an asp:checkboxlist bound to a datagrid.

    The datagrid contains a table with 3 columns: itemId, description and cost.

    In my checkboxlist I set the datatextfield property to the 'description'
    field from my datagrid and the datavaluefield property to the 'itemId'
    field. If I run this, it works as expected and produces a list similar to
    below (where x is a checkbox):

    x Item 1
    x Item 2
    x Item 3

    etc.

    What I'd like to do is to use both the description *and* the cost columns
    from my datagrid for the text field in the checkboxlist, e.g:

    x Item 1 (£10)
    x Item 2 (£23)
    x Item 3 (£5)

    Where 'Item 1' is contained in the 'Description' filed and '£10' is
    contained in the 'cost' field.

    My checkbox list tag currently looks like:

    <asp:CheckBoxList id="partsList" runat="server" DataMember="Part"
    DataTextField="Description" DataValueField="itemId"></asp:CheckBoxList>

    And then in my codebehind I set the DataSource of the list to be my DataGrid
    and call DataBind();

    Could anyone explain how to use multiple values in this way?

    Thanks
    Andrew
    Andrew Todd, Aug 13, 2003
    #1
    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:
    327
    =?Utf-8?B?TWlrZQ==?=
    Nov 21, 2003
  2. Morten
    Replies:
    2
    Views:
    684
    Morten
    Dec 19, 2003
  3. JD
    Replies:
    5
    Views:
    11,616
    NetArchitect
    Aug 8, 2007
  4. Patrick.O.Ige
    Replies:
    5
    Views:
    19,071
    Patrick.O.Ige
    Jun 19, 2005
  5. Replies:
    1
    Views:
    315
Loading...

Share This Page