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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted Apr 19, 2010, 7:28 AM EDT
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.
Ankit Jain10 reputationPosted Apr 19, 2010, 8:05 AM EDT
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 ChoudharyRank #145 · 15.8K reputationPosted Apr 19, 2010, 6:58 PM EDT
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.
Amit ChoudharyRank #145 · 15.8K reputationPosted Apr 19, 2010, 10:31 PM EDT
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.
Ankit Jain10 reputationPosted Apr 19, 2010, 11:19 PM EDT
Thanks,
Ankit Jain
Kirtan PatelRank #292 · 8.6K reputationPosted Apr 20, 2010, 12:00 AM EDT