473,789 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding attribute for each item in a checkbox list control

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
Nov 19 '05 #1
3 9973
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/ar...2/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" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
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

Nov 19 '05 #2
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 ListItemCollect ion (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
"vikram" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
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

Nov 19 '05 #3
Are you sure this approach works for ListItem? I agree that it works fine
for other controls, but I'm 99% sure that it doesn't work for
ListItems...try it...

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!)
"Prodip Saha" <ps***@bear.com > wrote in message
news:ew******** ******@tk2msftn gp13.phx.gbl...
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 ListItemCollect ion (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
"vikram" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23361
by: John R. | last post by:
I want to have a listbox that shows a checkbox and a textbox. I created a user control that has a checkbox and a textbox in it and have been trying to add it to a listbox but I can't get it to show up for each item I add to the listbox. foreach (Column column in columns) { ColumnsListBox.Items.Add(column.Name); ColumnsListBox.Controls.Add(new ColumnListControl(true, column.Name,
3
4885
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
2
2057
by: Stephen Lambie | last post by:
Hi, I want to develop a custom checkbox. I want to use the existing checkbox in a custom control where I use the disabled state as a third state. I need to be able to detect mouse or click events in the disabled checkbox or the parent custom control. Is this possible? How does a control like a button control implement event trapping like a click event?
1
3302
by: darkpeace | last post by:
Okay i'm at my wits end. I've tried every which way to add a simple onClick even to checkbox items in my code behind : example: Protected WithEvents chkSample As System.Web.UI.WebControls.CheckBoxList .... For Loop i = 0; i++ here
3
1462
by: Gummy | last post by:
Hello, I know I can use a Checkboxlist or a RadioButtonList to easily create a list based on the data passed to it. But using what if I wanted to use the same data and based on the data, return either a textbox or checkbox (or even a user control). What is the best way to do that? Thanks for the help.
1
4239
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
0
1567
by: djarmoluk | last post by:
I have a RadioButtonList (named rbAnswers) control within a repeater control. When binding to the repeater, I am trying to add an "OnChange" attribute to the individual list item controls (input controls of type radio) using the following syntax: For Each Item In rbAnswers.Items Item.Attributes.Add("OnChange", MethodName) Item.Enabled = False Next
0
1035
by: Kevin Blount | last post by:
I need to create a page that lists a users Content, and allow them to add subscribers to or remove subscribers from that Content. The list may contain just one Content item, but it could just as easily contain 10 Content items. Each Content item would look something like this: --------------------------------------------- <content title 1> <content description 1>
1
2467
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this guy's Javascript "combo box" - http://sandy.mcarthur.org/javascript/select/select.html. It allows my users (when I get some!) to select from a list of preexisting options and also to add a new one by clicking on "add new". Essentially it's a select...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.