Solved

ListView CheckBox Value

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

13 Experts available now in Live!

Get 1:1 Help Now