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


Reply With Quote