Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ListBox Items

Reply
Thread Tools

ListBox Items

 
 
=?Utf-8?B?QmFyZW4=?=
Guest
Posts: n/a
 
      04-12-2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VHUtVGhhY2g=?=
Guest
Posts: n/a
 
      04-12-2005
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

 
Reply With Quote
 
 
 
 
Terry Mulvany
Guest
Posts: n/a
 
      04-12-2005
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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




 
Reply With Quote
 
=?Utf-8?B?QmFyZW4=?=
Guest
Posts: n/a
 
      04-13-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy ListBox items to anoher listbox Tomas ASP .Net 1 08-12-2008 08:22 AM
unable to retrieve listbox items on postback , items moved usingjavascript between 2 list boxes (source and target ) divya ASP .Net 1 05-28-2008 05:27 AM
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
add items from one listbox to other listbox from javascript mc Javascript 0 12-02-2003 08:23 PM



Advertisments