Professional Web Applications Themes

parent child dropdownlists acting oddly - ASP.NET General

I've got two dropdownlists on my webusercontrol. Choosing an item from the first DDL restricts the data displayed in the second DDL. Unfortunately, in the SelectedIndexChanged event of the first DDL, the SelectedIndex is -1. I'm not refreshing the contents of the first DDL on the postback. When I step thru the code, the Page_Load executes as expected, but I do get an 'error' in the IDE when I step thru the code immediately after the this event that reads: 'There is no source code for the current location'. I don't know if this is affecting things or not. The ...

  1. #1

    Default parent child dropdownlists acting oddly

    I've got two dropdownlists on my webusercontrol. Choosing an item from the
    first DDL restricts the data displayed in the second DDL.

    Unfortunately, in the SelectedIndexChanged event of the first DDL, the
    SelectedIndex is -1. I'm not refreshing the contents of the first DDL on
    the postback.

    When I step thru the code, the Page_Load executes as expected, but I do get
    an 'error' in the IDE when I step thru the code immediately after the this
    event that reads: 'There is no source code for the current location'. I
    don't know if this is affecting things or not. The SelectedIndexChange
    event fires next, and indicates that SelectedIndex is -1.

    Does anyone know what's happening? Code is below.

    Thanks,

    Craig Buchanan

    <Code>
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then BindData()
    End Sub

    Private Sub BindData()
    BindDDL()
    End Sub

    Private Sub BindDDL()
    With Me.DropDownList1
    .DataSource = [stuff here]
    .DataBind()
    End With
    End Sub

    Private Sub BindLB(ByVal FolderId As Integer)
    With ListBox1
    .DataSource = [stuff here]
    .DataBind()
    End With
    End Sub

    Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal
    e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
    If Me.ListBox1.SelectedIndex > -1 Then
    Dim Value As Long = Me.ListBox1.SelectedItem.Value
    Dim Text As String = Me.ListBox1.SelectedItem.Text
    BindLB(Value)
    End If
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles ListBox1.SelectedIndexChanged
    If Me.ListBox1.SelectedIndex > -1 Then
    Dim Value As Long = Me.ListBox1.SelectedItem.Value
    Dim Text As String = Me.ListBox1.SelectedItem.Text
    RaiseEvent ListClicked(Me, New ListControlEventArgs(Value, Text))
    End If
    End Sub

    </Code>


    Craig Buchanan Guest

  2. #2

    Default Re: parent child dropdownlists acting oddly

    Looks like I'm testing for the listbox1 in the dropdownlist1's event.
    Changed the test and everything worked!

    "Craig Buchanan" <someonesomewhere.com> wrote in message
    news:OXR5wRLPDHA.1748TK2MSFTNGP11.phx.gbl...
    > I've got two dropdownlists on my webusercontrol. Choosing an item from
    the
    > first DDL restricts the data displayed in the second DDL.
    >
    > Unfortunately, in the SelectedIndexChanged event of the first DDL, the
    > SelectedIndex is -1. I'm not refreshing the contents of the first DDL on
    > the postback.
    >
    > When I step thru the code, the Page_Load executes as expected, but I do
    get
    > an 'error' in the IDE when I step thru the code immediately after the this
    > event that reads: 'There is no source code for the current location'. I
    > don't know if this is affecting things or not. The SelectedIndexChange
    > event fires next, and indicates that SelectedIndex is -1.
    >
    > Does anyone know what's happening? Code is below.
    >
    > Thanks,
    >
    > Craig Buchanan
    >
    > <Code>
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > If Not IsPostBack Then BindData()
    > End Sub
    >
    > Private Sub BindData()
    > BindDDL()
    > End Sub
    >
    > Private Sub BindDDL()
    > With Me.DropDownList1
    > .DataSource = [stuff here]
    > .DataBind()
    > End With
    > End Sub
    >
    > Private Sub BindLB(ByVal FolderId As Integer)
    > With ListBox1
    > .DataSource = [stuff here]
    > .DataBind()
    > End With
    > End Sub
    >
    > Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
    ByVal
    > e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
    > If Me.ListBox1.SelectedIndex > -1 Then
    > Dim Value As Long = Me.ListBox1.SelectedItem.Value
    > Dim Text As String = Me.ListBox1.SelectedItem.Text
    > BindLB(Value)
    > End If
    > End Sub
    >
    > Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e
    As
    > System.EventArgs) Handles ListBox1.SelectedIndexChanged
    > If Me.ListBox1.SelectedIndex > -1 Then
    > Dim Value As Long = Me.ListBox1.SelectedItem.Value
    > Dim Text As String = Me.ListBox1.SelectedItem.Text
    > RaiseEvent ListClicked(Me, New ListControlEventArgs(Value, Text))
    > End If
    > End Sub
    >
    > </Code>
    >
    >

    Craig Buchanan Guest

Similar Threads

  1. Parent and Child URL display
    By Jonathan-harrogate in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: February 13th, 04:23 PM
  2. Parent/Child relations - Trying to access child control for save
    By tnt_lu@hotmail.com in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: April 15th, 12:50 PM
  3. Use Parent Column in Child?
    By Allen Davis in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: May 1st, 08:39 PM
  4. Parent/Child Relationship
    By Bob Day in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: November 6th, 01:13 AM
  5. Transferring from parent to child
    By TuneRaider2k in forum FileMaker
    Replies: 3
    Last Post: October 9th, 09:40 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139