Click here to Skip to main content
15,914,608 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Dear Sir,

I have to select all the list items of the DataList control. This has to be done using JavaScript or JQuery. Use a separate button to select and de-select the items.

Please help me in this regard.

Thanks in Advance.
Posted
Updated 28-Apr-11 0:38am
v2

try this link

Clickhere[^]
 
Share this answer
 
Javascript for checking/unchecking all checkboxes

I believe the above information will be helpful.
 
Share this answer
 
i am not sure either you want to select some controls like all the checkboxes in your datalist, or you want to select all the text of all the datalist items?
anyways i generally do it in this way using selector in jquery :

if i want to select all the controls of type 'x' (can be input, span, table etc.) in my data list i give them all a class say 'classx'
on the onclick event of the seperate button use:

function xyz(){
$("x.classx").each(function(i) {
var val = this.value.toString();
-- do whatever you want with the value --
});
}


you can select in various diff ways like just by class doing : $(".classx").each(function(i) {..... blah blah
in your case you can use the id of data list followed by the html element you want to go thru like:
$("Your data list id.thing you want to select").each(function(i) {..... blah blah

hope this helps
thanks
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900