Adding attribute for each item in a checkbox list control

V

vikram

How can i add a user define attribute to each checkbox
item in a checkbox list control.
I want to add a attribute "Tag".
Is it possible
 
K

Karl Seguin

Vikram:
Not that I know of :( the ListItem (which is what each individual item is)
ignores the Attributes collection...

You could create your own CheckBoxList which extends the existing
CheckBoxList in a custom server control. You can check out how it was done
with this "special" DropDownList:
http://weblogs.asp.net/fmarguerie/archive/2003/02/27/3103.aspx

Should be somewhat helpful...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
P

Prodip Saha

Vikram,
I did for other controls (like datagrid, repeater, etc) and you may be able
to do with similar approach. Here is an outline-
You can intercept each Item of ListItemCollection (a collection of ListItem
object) in the collection in DataBinding event.

Then, you can add any attribute of your choice to the ListItem
object(ListItem.Attributes.Add...)

Thanks,
Prodip
www.aspnet4you.com
 

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,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top