Dynamic checkboxlist, how to assign an ID to a listitem


Is there a way to change the ID of a listitem in a checkboxlist. with the following code, when I look at the source HTML asp.net
generates its own ID's for the checkboxes.. and I havent found a way to assign an own ID to the checkbox listitems...
Another thing is when I create a listitem (text and value).. when I look at the source html, the Values are not present for the checkbox..

I need the values and the ID's to be retrieved from the form when submitting the form...

Dim checkbnew As New CheckBoxList
dim f_tekst as string
dim f_value as string

f_tekst = "text of the checkbox"
f_value = "value of the checkbox"

Dim lstitem As New ListItem(f_tekst, f_value)                        
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Private Sub Page_Load(ByVal sender As System.Object, ByValue As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Dim objListItem As New ListItem("joe", "millionaire")
Dim objListItem2 As New ListItem("regis", "philbin")
End If
end sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
End Sub


or you can just add your own objects. and you should also use multi-select list box
public class Student
  public overrides function toString() as string
    return fname_ & " " & lname_
  end function

  private fname_,lname_ as string
  public id_ as long

  public sub new(fname as string, lname as string, id as long)
  end sub
end class

in your form ...

mylistbox.items.add(new Student("Joe","Millionaire",1000000))
mylistbox.items.add(new Student("Regis","Philben",2000000))

dim x as integer
dim temp as Student
for x=0 to mylistbox.Items.Count-1
   if mycheckboxlist.Items(x).Selected then
      ' temp.id_  <===== this is your student id for the selected item
   end if

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: malharone {http:#9635440}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.