【发布时间】:2014-07-24 10:51:55
【问题描述】:
我想做的是在不同的 HTML 表中显示我在数据表中获得的记录。数据表中的记录有 3 列,我最多可以有 6 条记录。
我从数据库中得到的数据表如下:
Name Age
-----------
XYZ 30
XY1 31
XY2 32
XY3 33
我想通过以下方式显示记录:
Name Age Name Age
-----------------------
XYZ 30 XY1 31
Name Age Name Age
-----------------------
XY2 32 XY3 33
Total Strength of employees : 4
我目前在做的事情如下(虽然这不是我想要的,但是已经尝试过了):
<asp:Repeater ID="RptNCode" runat="server" OnItemCommand="RptNcode_ItemCommand"
OnItemDataBound="RptNCode_ItemDataBound" >
<HeaderTemplate>
<tr style="background-color: #507CD1; color:
White; font-weight: bold; text-align: center; height: 20px">
<td style="color: White;">
Sr.No
</td>
<td style="color: White; text-align: left">
Name
</td>
<td style="color: White; text-align: right">
Age
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #ffffff; height: 20px; font-family: Arial">
<td align="left" style="font-size: 15;">
<asp:LinkButton ID="lnkNCode" ForeColor="#336699" runat="server" Text='<%# Eval("Name") %>'
CommandArgument='<%# Eval("Name") %>' CommandName="NCode"></asp:LinkButton>
</td>
<td align="center" style="font-size: 15; text-align: right;">
<%# Eval("Age")%>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #ffffff; height: 20px; font-family: Arial">
<td align="left" style="font-size: 15;">
<asp:LinkButton ID="lnkNCode" ForeColor="#336699" runat="server" Text='<%# Eval("Name") %>'
CommandArgument='<%# Eval("Name") %>' CommandName="NCode"></asp:LinkButton>
</td>
<td align="center" style="font-size: 15; text-align: right;">
<%# Eval("Age")%>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
<tr>
<td align="right" height="40px">
<asp:Label ID="lblTotal" runat="server" Font-Bold="true" ForeColor="#336699"></asp:Label>
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
我知道这是不正确的,但这是我迄今为止所做的。我正在尝试做的事情是否可能?
谢谢。
【问题讨论】:
标签: asp.net c#-3.0 repeater datalist