V
viktor9990
I have several DropDownList Controls (ddlOrder, ddlContact...) where the user
may select multiple values and let the results be displayed in the datagrid.
I know how to filter when chosing from any of these dropdownlists. But don't
know how to filer if the user wants to filter based on selection of some of
these dropdownlists at the same time? Any Help? Thanks.
Here is my Code:
Private sub myFilter()
Dim objConn As SqlConnection
Dim strSql As String
strSql = "SELECT Company, Contact, Title, Phone " _
& "FROM Customers"
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet()
sdaCust.Fill(dstCust, "Customers")
Dim dtbCust As DataTable = dstCust.Tables(0)
Dim dtvCust As New DataView(dtbCust)
'" & ddlOrdr.SelectedItem.Text & "'"
dtvCust.RowFilter = "Company = '" & ddlOrder.SelectedItem.Text & "'"
dtvCust.Sort = "ContactName"
dtgCust.DataSource = dtvCust
dtgCust.DataBind()
End Sub
may select multiple values and let the results be displayed in the datagrid.
I know how to filter when chosing from any of these dropdownlists. But don't
know how to filer if the user wants to filter based on selection of some of
these dropdownlists at the same time? Any Help? Thanks.
Here is my Code:
Private sub myFilter()
Dim objConn As SqlConnection
Dim strSql As String
strSql = "SELECT Company, Contact, Title, Phone " _
& "FROM Customers"
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet()
sdaCust.Fill(dstCust, "Customers")
Dim dtbCust As DataTable = dstCust.Tables(0)
Dim dtvCust As New DataView(dtbCust)
'" & ddlOrdr.SelectedItem.Text & "'"
dtvCust.RowFilter = "Company = '" & ddlOrder.SelectedItem.Text & "'"
dtvCust.Sort = "ContactName"
dtgCust.DataSource = dtvCust
dtgCust.DataBind()
End Sub