Solved

ListView CheckBox Value

Posted on 2012-04-08
3
370 Views
Last Modified: 2012-06-27
I am trying to get the value of an ID("ToppingID") from a ListView in in VB.NET and add it to a list.

I can do it with the GridView like this:

Dim chk As CheckBox
Dim list As New List(Of String)
        
        For Each rowItem As GridViewRow In GridView1.Rows
            chk = CType(rowItem.Cells(0).FindControl("CheckBox2"), CheckBox)
            If chk.Checked Then
                list.Add(GridView1.DataKeys(rowItem.RowIndex)("ToppingID").ToString()) 
            End If
        Next

Open in new window


How do I do the same thing only with a list view?
What do I use instead of rowItem and RowIndex??
0
Comment
Question by:natethegreat1977
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37821153
For Each item As var In listView1.Items
	     Dim chkBox = TryCast(item.FindControl("chkId"), CheckBox)
             If chkBox .Checked Then
              'your code here...  
            End If
Next

Open in new window


Refer here as well:-
http://www.shotdev.com/aspnet/aspnet-vbnet-listview/aspnet-vbnet-listview-findcontrol/
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 38047924
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Calculating percentage 2 47
How to fix 'event logs could not be searched' error asp.net? 3 25
Removing Version of .NET in Windows 10 17 117
Help with Report Viewer in VS2013 6 31
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question