ListBox Items

Discussion in 'ASP .Net' started by =?Utf-8?B?QmFyZW4=?=, Apr 12, 2005.

  1. 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
     
    =?Utf-8?B?QmFyZW4=?=, Apr 12, 2005
    #1
    1. Advertising

  2. 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
     
    =?Utf-8?B?VHUtVGhhY2g=?=, Apr 12, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:D...
    > 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
     
    Terry Mulvany, Apr 12, 2005
    #3
  4. 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
     
    =?Utf-8?B?QmFyZW4=?=, Apr 13, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kent
    Replies:
    1
    Views:
    900
    Andrew de la Harpe
    May 3, 2004
  2. K B
    Replies:
    2
    Views:
    692
  3. divya
    Replies:
    1
    Views:
    1,113
    Munna
    May 28, 2008
  4. Tomas
    Replies:
    1
    Views:
    595
    Munna
    Aug 12, 2008
  5. mc
    Replies:
    0
    Views:
    255
Loading...

Share This Page