ListBox Items

G

Guest

Hi!

I have a generalized Stored Procedure to get the listbox items in a
datareader.Then i am binding the datareader to the listbox. For different
pages and different conditions i need to hide and show some the items
returned by the datareader.

Can anyone help me out to solve this issue.

Thanks in adavnce.
Baren
 
G

Guest

You can change the query to return the correct items on each page. If that's
not possible then you can loop through the Items collection and remove the
ones that should not be there.

foreach (ListItem item in listbox.Items)
{
if (item should not be there)
{
listbox.Items.Remove(item);
}
}
 
T

Terry Mulvany

Well you could use a dataset in place of a datareader and then use a
dataview based on the dataset to filter/sort the data based on
page/condition then re-bind the listbox.
 
G

Guest

Hi! Thach,

I am developing the site with codebehind as VB.NET.
i wrote the following code, but its givine one error
"Collection was modified; enumeration operation may not execute."

Dim item As ListItem
For Each item In selCategory.Items
If (item.Text = "System Alert") Or (item.Text =
"Underwriting Referral") Or (item.Text = "Inspection requested") Then
selCategory.Items.Remove(item)
End If
Next item

Can you help me??

Regards,
Baren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top