filtering from multiple dropdownlists

Discussion in 'ASP .Net Datagrid Control' started by viktor9990, Apr 19, 2005.

  1. viktor9990

    viktor9990 Guest

    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
     
    viktor9990, Apr 19, 2005
    #1
    1. Advertising

  2. viktor9990

    Elton W Guest

    Hi Viktor

    You can use

    dtvCust.RowFilter = "Company = '" &
    ddlOrder.SelectedItem.Text & "' AND ContactName = '" &
    ddlContactSelectedItem.Text & "'"

    HTH

    Elton Wang



    >-----Original Message-----
    >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
    >.
    >
     
    Elton W, Apr 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren

    Multiple DropDownLists

    Darren, Aug 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    Steve C. Orr, MCSD
    Aug 18, 2003
  2. Craig Buchanan

    reuse SQLDataReader in multiple dropdownlists?

    Craig Buchanan, Jan 12, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,331
    Craig Buchanan
    Jan 15, 2004
  3. Angel.Net
    Replies:
    1
    Views:
    367
    =?Utf-8?B?Q3JhaWc=?=
    Jun 15, 2005
  4. RSH
    Replies:
    3
    Views:
    437
  5. filtering from multiple dropdownlists

    , Jan 18, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    674
    Alvin Bruney [MVP]
    Jan 20, 2007
Loading...

Share This Page