problems with assigning specified indexes to checkboxlists

M

Mike Rogers

I am populating a checkboxlist:

Up to now I did this:
chkItem.DataSource = objDatareader
chkItem.DataTextField = "item_name"
chkItem.DataValueField = "item_ID_PK"
chkItem.DataBind()

but I can't add or string more than one field like this to the
datatextfield: (i need more information displayed!)

chkItem.DataTextField = "item_name" & " " & "item_desc"

How can I get around this?


I tried doing this:

Private Sub Page_Init(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim cbl As New CheckBoxList()
cbl.ID = "cblist1"
cbl.Items.Add(datareader("name") & " " & datareader("Desc"))

I will modify this using a list to read a dataareader in a loop and
assign a field name as the cbl.items...

but I dont want these assigned as 1, 2, : i want them as the
item_ID_PK field from the datareader. How do I assign the "index???"

Does anyone have any suggestions for either of these approches?
thanks and kind regards,
Mike
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top