• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

filtering results in listview by column name

HOw can I filter results in a listview control. I have 5 boolean fields that I would like to show in a drop down and filter on those columns. please help thanks
  • 2
1 Solution
you can use the
Selected Index change
property of
your Dropdown

and In the select Query
pass the id or the filter
option you want

and with selected index changed
event of Dropdown
Fill the Listview

try this..will work
More description please. What 5 fields? What columns are shown in Listview? How are you accessing data? Using AccessDataSource/SqlDataSource?
TrialUserAuthor Commented:
I call a SQL Server stored procedure to return data. I bind the Dataset.tables(0) to the listview on Page Load.

I have some boolean fields like : IsRecyclable, IsGreen, IsFreeShippable and so on.
I would like to have a drop down for these boolean fields like :
Show All, Only Green, Only ISFreeShippable = true

So is there anything inbuilt in asp:listview that I could take advantage of? Or should I have a drop down and on Selected Indiex change fetch data again from SQL and bind it? Please help thanks

You can apply the filter on the DataTable.


If DDL.Text = "Show All" Then
   dSet.Tables(0).DefaultView.RowFilter = ""
ElseIf DDL.Text = "Only Green" Then
   dSet.Tables(0).DefaultView.RowFilter = "IsGreen=True"
ElseIf ...
End If
Listview1.DataSource = dSet.Tables(0).DefaultView

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now