strange values for checkbox items

A

Andreas Bauer

Hi,

when the page loads I want to add items to a checkboxlist.
CheckBoxList cbprofiles = new CheckBoxList();

foreach (ProfileService.ProfileType p in profiles)
{
cbprofiles.Items.Add(new ListItem(p.name, p.id.ToString()));
}
ProfilesPlaceHolder.Controls.Add(cbprofiles);

p.id.ToString are normal integers. But when I look at the source code I
get this strange id values:
<tr>
<td><input id="ctl00_ContentPlaceHolder1_ctl00_0" type="checkbox"
name="ctl00$ContentPlaceHolder1$ctl00$0" /><label
for="ctl00_ContentPlaceHolder1_ctl00_0">Text1</label></td>

</tr><tr>
<td><input id="ctl00_ContentPlaceHolder1_ctl00_1" type="checkbox"
name="ctl00$ContentPlaceHolder1$ctl00$1" /><label
for="ctl00_ContentPlaceHolder1_ctl00_1">Text2</label></td>
</tr>

You could please explain this to me?

Best regards,

Andi
 
K

Ken Cox [Microsoft MVP]

That's just the ASP.NET system creating its own IDs. The IDs get quite
complicated if you include user controls in master pages.

It's completely normal.

Ken
 
A

Andreas Bauer

Ken said:
That's just the ASP.NET system creating its own IDs. The IDs get quite
complicated if you include user controls in master pages.

It's completely normal.
Ok. But I need the values for a database query and with the auto
generated values I can't do that. The values are not one in a row, they
can be 1, 3, 5, 4, 7 etc. Isn't possible to set your own values for the
checkbox?
 

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

Top