Multiple datatextfield values in checkboxlist

A

Andrew Todd

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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top