2012-08-11 48 views
0

如何在下面的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> 
+0

我們需要更多的背景: 我厭倦了消息「!哎呀你編輯不能提交,因爲」。您只發布了一個沒有其父容器或頁面本身的ItemTemplate。 – Dai 2012-08-11 00:11:45

+1

使用代碼隱藏功能,不要將您的邏輯與您的標記混合使用。 – IrishChieftain 2012-08-11 00:19:31

+0

大衛,我已經更新了代碼... – khurj 2012-08-11 00:33:09

回答