473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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 1985
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
by: 00_ChInkPoIntD12 | last post by:
Can anyone confirm there isn't a Sort() method for WebControl Listbox in Asp.net? It is rather simple to write a method to do the sorting, but just wondering I shouldn't invent the wheel if...
2
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
4
by: rn5a | last post by:
Can the items in a ListBox be sorted by the name of the items? The ListBox actually lists all directories & files existing in a directory on the server. Note that all the directories should be...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.