PDA

Click to See Complete Forum and Search --> : Embed For Loop


Ice725
Sep 10th, 2004, 02:08 PM
I'd like to loop though and display a given amount of images


<table>
<tr>
<%
dim x as integer
for x = 1 to 5
%>

<td><asp:Image ImageUrl='readrealimage.aspx?id=1' Width="84" Height="105" Runat=server />
</td>

<%
next
%>
</tr>
</table>


But instead of my id variable in the URL being 1, I need it to be the value of x from my loop?

Can someone help me out?

jas4th
Sep 13th, 2004, 04:20 AM
have you considered the repeater control or a db bound grid. Else you need to send out your html via something like response.write - there is also host of built in commands for contructing the elements of html in code.

tcorey08
Sep 22nd, 2004, 11:09 PM
I hate to ask, but why are you trying to use the Image control? It will slow down the processing on your page considerably because the server has to render the page twice for its control layout. A more resource-friendly approach would be to use something similar to the following:


<table>
<tr>
<%
Dim x As Integer
For x = 1 To 5
%>
<td><img src="readrealimage.aspx?id=<%= x %>" style="width: 84px; height: 105px;"></td>
<% Next %>
</tr>
</table>


T