•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 374,171 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,446 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 447 | Replies: 2
![]() |
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I would like to know how can I retrieve results/records from a database one at a time to make it appear in different labels..
eg.
row number 1 of the database's records = apple
lb_fruit.Text = apple
row number 2 of the database's records = pear
lb_fruit2.Text = pear
.
.
And so on..
There's loads of rows that I need to retrieve..
Is there anyway then better then writing loads of sql statements?
Thanks loads in advance. (:
eg.
row number 1 of the database's records = apple
lb_fruit.Text = apple
row number 2 of the database's records = pear
lb_fruit2.Text = pear
.
.
And so on..
There's loads of rows that I need to retrieve..
Is there anyway then better then writing loads of sql statements?
Thanks loads in advance. (:
•
•
Join Date: May 2005
Posts: 494
Reputation:
Rep Power: 4
Solved Threads: 18
Yes, load them into an array and then for each on the array and display the entire array and build labels as needed.
•
•
Join Date: Sep 2007
Posts: 1,054
Reputation:
Rep Power: 3
Solved Threads: 61
I would stay away from the array, as there is no need to use more resources since you are already using a datareader to read the data into an array. Your best bet is to put a repeater (depending on your situation and where these labels are placed), and binding it to the repeater.
This will spit out information in this manner:
Apple
Banana
Orange
Pear
Zucchini
VB.NET Syntax (Toggle Plain Text)
Dim dtrReader As SqlDataReader = cmdSelect.ExecuteReader() If dtrReader.HasRows Then repeater1.DataSource = dtrReader repeater1.DataBind() End If ------------ <asp:Repeater ID="repeater1" runat="server"> <ItemTemplate> <asp:Label ID="lbl" Text='<%# Eval("fruitorColumnName") %>' runat="server" /> <br /> </ItemTemplate> </asp:Repeater>
Apple
Banana
Orange
Pear
Zucchini
I answer pm's.
I answer questions.
I answer quickly.
I answer.
I answer questions.
I answer quickly.
I answer.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
age amd aol avatar backup blodget blue gene breach business chips daniweb data data protection database development dos economy energy enterprise europe google government hacker hardware hp ibm ibm. news linux medicine memory microsoft news open source openoffice pc ps3 recession red hat security server sun supercomputer supercomputing survey technology time warner trends ubuntu working x86
- Auto Email Reminder (ASP.NET)
- Login through database (ASP)
- Database Design help for stores (Database Design)
- retrieving current record in database (Visual Basic 4 / 5 / 6)
- vb6.0 combo box (Visual Basic 4 / 5 / 6)
- ASP.NET Tutorial: Caching in ASP.NET (ASP.NET)
- please take some time to help me.. thank you very much! (C#)
- ASP.net/Stored Proc & Login Verification (ASP.NET)
- Display Large amount of data (MS Access and FileMaker Pro)
- noobie asking for assistance with file parsing... (Perl)
Other Threads in the ASP.NET Forum
- Previous Thread: Datagrid
- Next Thread: How to show output with my condition from table with vb.net



Linear Mode