Results 1 to 2 of 2

Thread: Dropdownlist OnSelectedIndexChanged event in edit mode of datalist

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    142

    Dropdownlist OnSelectedIndexChanged event in edit mode of datalist

    Hey Guys,
    I have 2 dropdown lists in a datalist that are populated when you enter into edit mode. I was wondering how to changed the second dropdownlist's datasource when the first one's OnSelectedIndexChanged event is fired.

    I put this code in the first dropdownlist
    VB Code:
    1. OnSelectedIndexChanged=SelectionChanged

    and this in the codebehind:

    VB Code:
    1. Sub SelectionChanged(ByVal sender As Object, _
    2.                        ByVal e As DataListCommandEventArgs)
    3.         Dim strCategoryID As String
    4.         Dim subcat As DropDownList
    5.  
    6.         strCategoryID = CType(e.Item.FindControl("Category1"), _
    7.                                   DropDownList).SelectedItem.Value
    8.  
    9.         Dim objConnection As OleDbConnection
    10.         Dim objCommand As OleDbCommand
    11.         Dim strSQLQuery As String
    12.         Dim groupid As OleDbDataReader
    13.  
    14.  
    15.  
    16.         objConnection = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    17.  
    18.  
    19.  
    20.         strSQLQuery = "Select * from subgroupsingroups where idGroup=" & CInt(strCategoryID)
    21.         objConnection.Open()
    22.  
    23.  
    24.  
    25.         objCommand = New OleDbCommand(strSQLQuery, objConnection)
    26.  
    27.         groupid = objCommand.ExecuteReader()
    28.  
    29.  
    30.         objConnection.Close()
    31.  
    32.         subcat = e.Item.FindControl("Category2")
    33.         subcat.DataSource = groupid
    34.         subcat.DataBind()
    35.  
    36.  
    37.     End Sub

    I need to figure out how to pass the two arguments(Byval sender As Object, ByVal e As DataListCommandEventArgs) from the dropdownlist to the Sub SelectionChanged.

    Any ideas???

    Thanks,
    Bebandit

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    Sheffield, UK
    Posts
    35

    Re: Dropdownlist OnSelectedIndexChanged event in edit mode of datalist

    Hi,

    I also am having a similar problem but I just want to use the info from the dropdownlist to put this into a calendar control but it is basically the same idea as bebandit is doing.

    Any help would be great!!

    Thanks
    www.warriornation.net

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