Draw html with loop?

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I am new to ASP.NET and am trying to convert an old ASP project to a C# web
application. I have a page with a very long form on. On part of the form
has a series of comboboxes that a populated with data from a database. In
my old ASP project I wrote the HTML doing something like this

<% for i = 1 to 10 %>
<tr>
<td><select name='test'><option value='<%= i %></option><.select></td>
</tr>
<%next%>

This is not the exact code an is abbreviated just for this post. How do I
do something similar in .NET? Also, is there a way of doing this with a set
of radio buttons with having to use the radiobuttonlist control? I think
the design options are a little limited for this control.

Thanks.

Rob
 
You can do exactly the same thing if you are using inline code. That would
be the easy way for a quick conversion. Or call a function inline, and have
the Response.Write() calls in the function.

Otherwise, use one of the bindable controls (repeater, datalist, etc), and
either add rows to the datalist in a loop or make a collection or array and
bind to the list.

Jeffrey Palermo
 
Use a DataList, DataTable or DataRepeater Control.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top