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:
OnSelectedIndexChanged=SelectionChanged
and this in the codebehind:
VB Code:
Sub SelectionChanged(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
Dim strCategoryID As String
Dim subcat As DropDownList
strCategoryID = CType(e.Item.FindControl("Category1"), _
DropDownList).SelectedItem.Value
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim strSQLQuery As String
Dim groupid As OleDbDataReader
objConnection = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
strSQLQuery = "Select * from subgroupsingroups where idGroup=" & CInt(strCategoryID)
objConnection.Open()
objCommand = New OleDbCommand(strSQLQuery, objConnection)
groupid = objCommand.ExecuteReader()
objConnection.Close()
subcat = e.Item.FindControl("Category2")
subcat.DataSource = groupid
subcat.DataBind()
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
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