Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. filtering from multiple dropdownlists

filtering from multiple dropdownlists

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    viktor9990
    wrote on last edited by
    #1

    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) dtvCust.RowFilter = "Company = '" & ddlOrder.SelectedItem.Text & "'" dtvCust.Sort = "ContactName" dtgCust.DataSource = dtvCust dtgCust.DataBind() End Sub

    M 1 Reply Last reply
    0
    • 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) dtvCust.RowFilter = "Company = '" & ddlOrder.SelectedItem.Text & "'" dtvCust.Sort = "ContactName" dtgCust.DataSource = dtvCust dtgCust.DataBind() End Sub

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You can create an expression based on the selection of the dropdownlists and assign to the RowFilter property. You can take a quick look at these to learn more: DataView.RowFilter Property[^] DataColumn.Expression Property[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups