parent child dropdownlists acting oddly

Ask a Question related to ASP.NET General, Design and Development.

  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. Similar Questions and Discussions

    1. Parent/Child relations - Trying to access child control for save
      I have a parent datagrid that has my customer information. For each customer I have a child datagrid with all their part information. In the...
    2. removing a child from a parent
      is it possible to remove a child from a parent WITHOUT removing it from the world? if I set its parent to VOID it removes it from the world. I want...
    3. Use Parent Column in Child?
      Is there a way to retrieve a column from the parent table of a relationship and display it in the child data control? In my case, I'd like to show a...
    4. Parent/Child Relationship
      Using VS 2003, VB.NET, sql msde... This is really a question about a winform datagridcontrol (if there is a better newsgroup for these winform...
    5. Transferring from parent to child
      I was given some direction about a loop step, but I need help with step syntax within the loop. The following is what I have so far, it presently...
  3. #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" <someone@somewhere.com> wrote in message
    news:OXR5wRLPDHA.1748@TK2MSFTNGP11.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

Posting Permissions

  • You may not post new threads
  • You may 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