473,387 Members | 1,606 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,387 software developers and data experts.

checkboxlist and datavaluefield

Hi,

Is there anyway to get the datavaluefield from a databound checkboxlist
using javascript?

If not, is there any way to associate a custom attribute with the databound
checkboxlist items so that the custom attribute can be accessed using
javascript?

Cheers
Nov 19 '05 #1
3 5500
> Is there anyway to get the datavaluefield from a databound checkboxlist
using javascript? If you mean getting the name of the field on client side, the answer is no.
If not, is there any way to associate a custom attribute with the databound checkboxlist items so that the custom attribute can be accessed using
javascript?

Sure. ListItem has Attributes property. That's where you can put any
attribute.

Eliyahu
Nov 19 '05 #2
As an alternative, hidden controls can be used to store these
parameters so that they can be easily picked up with client side code.

Bill E.

Nov 19 '05 #3
Thanks for the suggestions...

I've tried adding a custom attribute to the ListItems by iterating through
all the ListItems after the CheckBoxList has been databound and adding a new
custom attribute that holds the DataValueField value for each ListItem.

However, looking at the html when the CheckBoxList is rendered, the
individual html checkbox input controls that the CheckBoxList becomes do not
have the custom attribute I added. Perhaps I am doing something wrong or
adding the custom attributes at the wrong time...I'm adding them in Page_Load
when it is not a postback, that is, the first time the page is accessed.

As for the hidden input controls approach, I'm not entirely sure how I would
link the hidden controls to the individual html checkboxes that are
rendered...I can dynamically add a bunch of hidden controls which hold the
DataValueField values for each ListItem...but how do I tell which hidden
input control refers to which html checkbox control? I guess one way around
this would be to try to add a custom attribute to the hidden controls to hold
the id of the checkbox that each one refers to.

I guess my problem is that when the CheckBoxList is rendered into individual
html checkbox inputs, those checkbox inputs only have id, name and checked
attributes on client-side and lose their mapping to the data the CheckBoxList
was bound to.

I'm trying to get the DataValueField on client-side because I'm trying to
implement a client-side validation function on the CheckBoxList items...so
when a user checks a particular CheckBoxList item, the validation should
check that a bunch of other controls are completed. The server-side
validation for this is working fine so maybe I'll just leave it as a
server-side only validator.

Cheers again, Dune
Nov 19 '05 #4

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

Similar topics

0
by: wjer | last post by:
I am trying to do two things for a test app: 1) Populate a CheckboxList webcontrol by loading a list of subject names (for the DataTextField) and subject codes (for the DataValueField). 2)...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Patrick.O.Ige | last post by:
I have some boolean value(1 or 0 ) in a table and i want a databinded CheckBoxList to present the selected values on the page.. With CheckBox i know i can se the Checked property like so :-...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
2
by: Patrick.O.Ige | last post by:
I have a Checkboxlist that is databinded and i want to pass it a boolean value from a table because i want to display the checked values if its TRUE. When Databinding my checkboxlist i'm not...
0
by: Nam | last post by:
I want to use the same sqlDataSource for two CheckBoxList controls in ASP.NET 2.0. For simplicity, I am using the case of only two CheckBoxList controls in the following example: My...
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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,...
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
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,...
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.