For each loop

  • Thread starter Thread starter nina297
  • Start date Start date
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
 
Bind your data reader to a Repeater control, or something similar like a
DataGrid.

Google will give you specific code examples.
 
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!
************************************************
 
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?
 
Back
Top