Solved

ASP.net VB.net Get the Index of an Item checked in a dynamically added CheckBoxList

Posted on 2016-10-21
9
52 Views
Last Modified: 2016-10-21
Hi
I am trying to get the Index of an Item checked in a dynamically added CheckBoxList. I use the following code and
myCheckBoxListName  and myNewValue work just fine but oIndex returns -1 every time

  Private Sub HandleCheckBoxListOnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

            Dim myCheckBoxListName As String
            Dim myNewValue As String
            Dim oIndex As Integer

            myNewValue = DirectCast(sender, CheckBoxList).SelectedValue
            oIndex = DirectCast(sender, CheckBoxList).SelectedIndex
            myCheckBoxListName = DirectCast(sender, CheckBoxList).ID
End Sub
0
Comment
Question by:murbro
  • 5
  • 4
9 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41853363
Is it a multi select check listbox ?  (They don't use the SelectedIndex - that is just for single selection)
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41853368
0
 

Author Comment

by:murbro
ID: 41853649
Hi. That doesn't work. It is a CheckBoxList not a ListBox
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41853660
Answer the question please. Is it a multi select check listbox ?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:murbro
ID: 41853686
It is a CheckBoxList as I just said. This is automatically multi select
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 41853697
OK, that is why your SelectedIndex fails.

You will have to loop through the items and check each individually if it is selected to build up your collection of indexs.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41853703
ps.  re your attention request:
Hi

The tone of the person answering the question is not that polite. I think another expert should help or the question be deleted.

Thanks


What is impolite for asking you to answer a question you know the answer to, everyone else doesn't know the answer to and is critical to be able to explain why your code doesn't work?
0
 

Author Comment

by:murbro
ID: 41853710
I asked for the request to be ignored. I probably just interpreted your question differently to the way it was meant
0
 

Author Closing Comment

by:murbro
ID: 41853713
Thanks for the help
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

Suggested Solutions

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 …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

22 Experts available now in Live!

Get 1:1 Help Now