468,268 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

ListBox Items

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
Nov 19 '05 #1
3 1805
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);
}
}

"Baren" wrote:
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

Nov 19 '05 #2
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.

"Baren" <Ba***@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
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


Nov 19 '05 #3
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
"Tu-Thach" wrote:
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);
}
}

"Baren" wrote:
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

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris Leuty | last post: by
7 posts views Thread by 00_ChInkPoIntD12 | last post: by
7 posts views Thread by Dave | last post: by
3 posts views Thread by Ali Chambers | last post: by
4 posts views Thread by rn5a | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.