ASP.NET ListView select and highlight line through checkbox

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 ?

Answers


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
}

Need Your Help

C++ - calling a method from a class template

c++ templates class hashtable functor

I'm currently having a problem with a class template in C++. I'm currently making a hash table.

Retrieving id from database displayed and passing onto other page

html

I'm displaying the contents of a database on a particular page(recipe names).

Graphviz for documentation

uml doxygen documentation-generation graphviz

I noticed that doxygen uses the graphviz library for creating diagrams. Have you ever used graphviz for generating documentation? Is it worth learning the graphviz for documentation purposes outsid...