Results 1 to 5 of 5

Thread: OnSelectedIndexChanged Doesn't work *Resolved*

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    56

    OnSelectedIndexChanged Doesn't work *Resolved*

    hi all;
    I have place the following code in a OnSelectedIndexChanged sub..

    Here is the code...
    VB Code:
    1. Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
    2. LISTBOX2.ITEMS.CLEAR
    3. dim selectstring as string
    4. Dim cn1 As OleDbConnection = New OleDbConnection(ConfigurationSettings.appSettings("connectionstring"))
    5. cn1.Open()
    6. selectString  = "select question_id, Question from questions where exam_id = " & listbox1.selecteditem.value
    7. Dim cmd1 As OleDbCommand = New OleDbCommand(selectString, cn1)
    8. Dim reader1 As OleDbDataReader = cmd1.ExecuteReader()
    9. dim liadd as listitem
    10.  
    11. while(reader1.read())
    12. liadd = new listitem
    13. liadd.text = reader1("question").tostring
    14. liadd.value = reader1("question_id").tostring
    15. listbox2.items.add(liadd)
    16. end while
    17. End Sub

    But it doesn't work. As you can see it must refresh the values of a list box, but simply nothing happens...

    Is there a mistake somewher ????

    Thanks
    Last edited by ahmedabugh; May 12th, 2005 at 12:45 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: OnSelectedIndexChanged Doesn't work

    What code do you have for the listbox in the HTML source?

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    56

    Re: OnSelectedIndexChanged Doesn't work

    Hi,

    VB Code:
    1. <asp:ListBox id="ListBox1" runat="server" Width="279px" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" Height="102px"></asp:ListBox>

  4. #4
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: OnSelectedIndexChanged Doesn't work

    You need to set the AutoPostBack property to true.

    HTH

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    56

    Re: OnSelectedIndexChanged Doesn't work

    you r right, that was my mistake..

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width