在asp.net中的While或For循环
问题描述:
如何在下面的asp.net中使用For循环?我试图使用<%(int i = 0; i < 5; i ++)%>,这给我语法错误。在代码隐藏在asp.net中的While或For循环
<asp:ListView runat="server" ID="EmployeesListView" DataSourceID="EmployeesDataSource" DataKeyNames="EmployeeID" OnDataBound="grd_RowDataBound">
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblEmployees" name="tblEmployees" style="width:100%" color="green">
<tr id="Tr3" runat="server" style="background-color: red; color: yellow">
<th id="lbl1" style="display:none">Record No.</th>
</tr>
<tr runat="server" id="itemPlaceholder"></tr>
</table>
<asp:DataPager runat="server" ID="DataPager" PageSize="5">
<Fields>
<asp:NumericPagerField ButtonCount="5" PreviousPageText="<--" NextPageText="-->" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<td valign="top" class="tdWithBorder" width="165" align="right" style="background-color: #D7E0EC; color: blue">
<asp:Label ID="lblCallStatus" runat="server" Text='Call Status' />
<br />
<asp:Label ID="lblHoursWorked1" runat="server" Text='HoursWorked' />
<br />
<asp:Label ID="lblOTMealsPaid" runat="server" Text='Meals Paid'/>
<br />
</td>
</tr>
</ItemTemplate>
我们需要更多的背景: 我厌倦了消息“!哎呀你编辑不能提交,因为”。您只发布了一个没有其父容器或页面本身的ItemTemplate。 – Dai 2012-08-11 00:11:45
使用代码隐藏功能,不要将您的逻辑与您的标记混合使用。 – IrishChieftain 2012-08-11 00:19:31
大卫,我已经更新了代码... – khurj 2012-08-11 00:33:09