For each loop

N

nina297

Good morning,

How do I set up a For each loop to loop through my records in the
database?

My fields are topics, question and answers. I want the one topic
displayed that goes with each quesiton and answer. I'm using a data
reader to get the data.

Thanks.

Nina
 
A

Aidy

Bind your data reader to a Repeater control, or something similar like a
DataGrid.

Google will give you specific code examples.
 
C

Cowboy \(Gregory A. Beamer\)

Are you displaying them for the user as a list on a page (not necessarily a
grid, but question after question)?

If so, don't loop.

You can set up the questions in a Repeater. If you need to do something
custom, use the OnDataBinding event to handle the individual rows and
customize the output.

But, if you go back to looping, it means you will likely be writing out
custom HTML, which is a slow way to output in a binding world.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
 
N

nina297

Are you displaying them for the user as a list on a page (not necessarily a
grid, but question after question)?

If so, don't loop.

You can set up the questions in a Repeater. If you need to do something
custom, use the OnDataBinding event to handle the individual rows and
customize the output.

But, if you go back to looping, it means you will likely be writing out
custom HTML, which is a slow way to output in a binding world.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!







- Show quoted text -

Yes I am displaying the question after question with the answer
underneath the correct question.

I'll try the repeater only thing is I have the questions set up under
categories which I call topic. I don't want the topic to appear with
each question just want them grouped together. Any suggestions?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top