Solved

ListView CheckBox Value

Posted on 2012-04-08
3
363 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now