Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-10-21
9
Medium Priority
?
76 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:Murray Brown
[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 45

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 45

Expert Comment

by:AndyAinscow
ID: 41853368
0
 

Author Comment

by:Murray Brown
ID: 41853649
Hi. That doesn't work. It is a CheckBoxList not a ListBox
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 45

Expert Comment

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

Author Comment

by:Murray Brown
ID: 41853686
It is a CheckBoxList as I just said. This is automatically multi select
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 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 45

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:Murray Brown
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:Murray Brown
ID: 41853713
Thanks for the help
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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