Solved

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

Posted on 2016-10-21
9
62 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41853660
Answer the question please. Is it a multi select check listbox ?
0
 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change to file doesn't show up 16 74
ASP.net Markup for Sub Menu 2 39
Get sourcecode path 14 46
Validation for a field in asp.net 3 10
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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