Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:21:28+00:00 2026-06-05T21:21:28+00:00

Code for button: Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles

  • 0

Code for button:

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
    Dim li1 As ListItem
    Dim addList As New List(Of ListItem)

    If (ListBox1.SelectedIndex < 0) Then 'No user selected
        MsgBox("Please select a user to add from the Listbox on the left.", vbCritical, "ListBox2 Validation Error")
    Else
        For Each li1 In ListBox1.Items
            If li1.Selected = True Then
                adduser(li1.Selected.ToString, intKL)
            End If
        Next
    End If
End Sub

Items are cleared and added using:

ListBox2.Items.Clear()

and

While SQLdr.Read()
            If SQLdr.Item(0).ToString <> "" And SQLdr.Item(1).ToString <> "" Then
                ListBox2.Items.Add(SQLdr.Item(1).ToString & " - " & SQLdr.Item(0).ToString)
            End If
        End While

Updates are happening on the load of a dropdownbox

This has something to do with autopostbacks and the page load I think, can someone please help

When I click the add button even if I have selected an item in the listbox, it will always return an error message. I don’t think the listbox changedselected item is firing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:21:30+00:00Added an answer on June 5, 2026 at 9:21 pm

    Thanks kolin, your comment really helped.

    The problem was that I was populating the listbox on dropbox1_load subroutine and hence everytime a postback was made the listbox would repopulate and no selection could every be made. SelectedItem would revert to -1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ResourceObject
Here is the code for the button click event; Protected Sub CompetenciesButton_Click(ByVal sender As
I am using VB.NET and below code on button click event. Protected Sub ibtnSendInvites_Click(ByVal
Here's what I had so far, code-wise: Protected Sub btnAddRow7_Click(ByVal sender As Object, ByVal
I use this code in my VB.Net application Protected Sub btnBHNas_Click(ByVal sender As Object,
Time to learn some basics. Look at the code below: protected void Button1_Click(object sender,
HTML <body> <form id=form1 runat=server> <asp:Button runat=server ID=a OnClick=a_Click Text=apd/> </form> </body> Code protected
I wrote download excel file in my code. If I click download button I
Dim List As New List(Of DateTime) Then in my button click event: If InputBookinglength.SelectedValue.ToString
Code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // fileReader(); new xyz().execute(); }//

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.