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 8096201
In Process

The Archive Base Latest Questions

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

I have a form with a dropdownbox two listboxes and two buttons on it.

  • 0

I have a form with a dropdownbox two listboxes and two buttons on it.

I removed a “select” button as I just used the DropDownList1_SelectedIndexChanged, but the event would not fire until I used the suggestion from:
Why DropDownList.SelectedIndexChanged event does not fire?

It involved changing the AutoPostBack='true' and EnableViewState="true" properties

So now the DropDownList works but with the two listboxes, the SelectedIndex stays as -1 and does not change even when selected.

Listbox code:

<asp:ListBox ID="ListBox1" runat="server" EnableViewState="true" 
    Height="207px" Width="168px"></asp:ListBox>

DropDownList Code:

<asp:DropDownList ID="DropDownList1" runat="server" EnableViewState="true"
    AutoPostBack="true" style="font-weight: 700; margin-left: 26px">

Button click event code:

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

The MsgBox now always says no user has been select but there is a user select, very weird.

Any ideas? I think it has something to do with post backs, page_load or the selectedindex changed event of the listbox, it worked perfectly before I made the modifications.

  • 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:22:37+00:00Added an answer on June 5, 2026 at 9:22 pm

    The problem was the postback and that the code to populate the listboxes was in a dropbox_load subroutine. This meant that the listbox would repopulate everytime something changed on the page and hence the selecteditem index would revert back to -1.

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

Sidebar

Related Questions

I have form with few buttons and I want to know what button is
I have form with 1 button. when you click on the button 3 others
I have an RMA form that I've been able to add fields dynamically, but
I have form area in my view. If I click button A , I
I have form with button and checkbox. if i hit button static void is
I have form where before i was using simple post with <button name=submit id=register
I have the following dropdown box <form name=myform method=POST ACTION=songs.php> Select Category: <select id=sel
I have been working on quite a complex accordion/form recently and have a select
I have form where are 2 input fields and then i have dynamic dataTables
I have form where user submits field. Field can have letters, numbers, and punctuation.

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.