I have a List View . And i want to Filter item of this list view through Combo box. if i select any item from combo box then show only thoes item of list view in List View.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Apr 20, 2010, 4:00 AM
Ankit JainPosted Apr 20, 2010, 3:19 AM
Thanks,
Ankit Jain
Amit ChoudharyPosted Apr 20, 2010, 2:31 AM
Previously i was thinking that you were asking about asp.net controls..
Try to filter the listview like this..
private void EventLogcomboBox_SelectedIndexChanged(object sender, EventArgs e)
{
EventLogcomboBox.Items.Clear(); //Clear all the Data in the ListView
foreach (DataRow row in Datatable1.Rows)
{
switch (EventLogcomboBox.SelectedIndex)
{
case LAS_Appl_Constants.SEVERITY_LOW:
ListViewItem item = new ListViewItem(row["id"].ToString());
item.SubItems.Add(row["name"].ToString());
listView1.Items.Add(item); //Add this row to the ListView
break;
case LAS_Appl_Constants.SEVERITY_MEDIUM:
//similarly you can add other case here...
break;
default:
break;
}
}
Please mark as answer if it helps.
Amit ChoudharyPosted Apr 19, 2010, 10:58 PM
onSelectedindexchanged event of the DropDownlist you can filter the DataTable using the Value field of Dropdownllist.
hope it helps you otherwise send me your project files i'll do it for your.....
Please mark as answer if it helps.
Ankit JainPosted Apr 19, 2010, 12:05 PM
Thanks,
i have a list View. There is number of item in List View. In this List View one column has Icon like error, Warning icon. if i select error from combo box then ListView show only error. if i select warning from Combo Box then ListView show Warning only.....
Amit ChoudharyPosted Apr 19, 2010, 11:28 AM
if you are binding the listview with datatable then you can filter the data inside the datatable on the basis of your Combobox/DropDownlist and rebind the listview with the new filetered Datatable.
You can also use DataView class to filter the data from datatable and bind the filtered view to the listview.
Please mark as answer if it helps.