Filtered Binding List questions / best practicesFiltered Binding List questions / best practices
Old forum URL: forums.lhotka.net/forums/t/2609.aspx
colema18 posted on Thursday, March 29, 2007
Can Rocky and others look over the code below and point out some improvemetns I can make. I noticed that the applyfilters is not stackable unless you create another filteredList and through the first filtered list into it - so hopefully I am doing that right. bulletins.Count isn't ever null here, but it appears taht if bulletins.count = 0, then any filtered or sorted lists based on the empty collection of bulletins is null instead of empty (which makes .count blow up). So am I supposed to check for null on filtered and sortedlists instead of count = 0.
BulletinList bulletins;
FilteredBindingList<BulletinInfo> filteredBulletins;
SortedBindingList<BulletinInfo> sortedBulletins;
...
bulletins = BulletinList.GetBulletinList(_dealerNumber, int.Parse(ddLastDays.SelectedValue));
...
if (bulletins.Count != 0)
{
FilteredBindingList<BulletinInfo> filteredLangBulletins = new FilteredBindingList<BulletinInfo>(bulletins);
filteredLangBulletins.ApplyFilter("Language", Page.UICulture);
filteredBulletins = new FilteredBindingList<BulletinInfo>(filteredLangBulletins);
if (ddBulletinType.SelectedValue != "All")
{
filteredBulletins.ApplyFilter("ProductType", ddBulletinType.SelectedValue);
}
}
sortedBulletins = new SortedBindingList<BulletinInfo>(filteredBulletins);
sortedBulletins.ApplySort(sortBy, sortOrder);
Session[keySort] = sortedBulletins;
if (sortedBulletins.Count != 0)
{
BindGrid(sortedBulletins);
...
Copyright (c) Marimer LLC