Adding attribute for each item in a checkbox list control

  • Thread starter Thread starter vikram
  • Start date Start date
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
 
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!)
 
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
 
Back
Top