473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Add Attribute to CheckBoxList ListItem at runtime?

CK
Hi All,
I have an asp:CheckBoxList. it is databound to a datatable at runtime;

private void chklstStatuses_DataBinding(object sender, EventArgs e)

{

chklstStatuses.DataSource = BillingInvoiceUtil.GetStatuses();

chklstStatuses.DataTextField = "StatusName";

chklstStatuses.DataValueField = "InvoiceStatusID";

}

I need to add an attribute to each list item,
"onClick=javascript:setFilter(this);"

I can not get it to work. I tried two different methods in two different
events, in chklstStatuses_DataBinding & in chklstStatuses_PreRender.

I try it like this

for(int x = 0; x != chklstStatuses.Items.Count; x++)

{

ListItem li = chklstStatuses.Items[x];

li.Attributes.Add("onClick","javascript:setFilter( this);");

}

doesn't work and I also tried
IEnumerator chklstEnumerator;

ListItem li;

chklstEnumerator = chklstStatuses.Items.GetEnumerator();

while(chklstEnumerator.MoveNext())

{

li = (ListItem)chklstEnumerator.Current;

li.Attributes.Add("onClick","javascript:setFilter( this);");

}

Neither one of these methods renders the attribute. I a compile fine and i
get no runtime or javascript errors in either case. I view the page source
and the attribute just doesn't seem to render.
Can anyone help?

Thanks,
~CK
May 23 '06 #1
0 1993

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

Similar topics

4
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something...
2
by: Simon Cheng | last post by:
Hi, For the following form: <form runat="server"> <asp:checkboxlist id="list" runat="server"> <asp:listitem runat="server" value="Cash" /> <asp:listitem runat="server" value="Check" />...
3
by: Jack Black | last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages... Hi, all! I've been struggling with getting a dynamically-generated CheckBoxList generated. I've finally been able to get the...
14
by: Satheesh Babu B | last post by:
hai.. am having a checkboxlist..now how do i get the value of the checkbox that is checked in checkboxlist using javascript? Thanks in advance.... Regards,
0
by: CK | last post by:
Hi All, I have an asp:CheckBoxList. it is databound to a datatable at runtime; private void chklstStatuses_DataBinding(object sender, EventArgs e) { chklstStatuses.DataSource =...
3
by: Sully | last post by:
Hi, I am having a small problem generating an e-mail via an online form. I am creating an e-mail using the MailMessage command and I know that you have to do something special to render the values...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
4
by: Marty | last post by:
I am using: VS2005 Pro WinXP Pro SP2 IIS 5.1 ..NET Framework 2.0.50727 I create a website using File>New>Web Site>ASP.NET. I put a ListBox, DropDownList, CheckBoxList and RadioButtonList on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.