I am trying to get an ASP.NET 3.5 ListView control to select and highlight lines through checkboxes displayed in the first column. If I use an asp:LinkButton instead of a checkbox, the line selection is supported automatically through the LinkButton's property CommandName="Select". How do I do that with the checkbox? And as soon as I managed to do that, how do I get the selected items on pressing a submit button on the form ?
+1
A:
I'm not sure if I'm following what you're trying to achieve, do you want a visual change when you check the checkbox? If so the best option would be using jQuery and attach to the onchange event of the checkbox.
Then when you postback the form you can itterate through the items within the ListView and locate the checkbox, check its checked state and then do what you want:
foreach(var item in listView1.Items){
var checkbox = (CheckBox)item.FindControl("checkBox1");
if(checkbox.Checked) // do stuff
}
Slace
2008-12-01 11:06:55