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 ?


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

Entity Framework and appending VARBINARY field

c# entity-framework varbinary

i am trying to add bytes of a file to a field in the database which is of type VARBINARY bu this needs to be appended due to file size constraits

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.