我试图控制转发器的输出。
我确实有一个很好的工作中继器,但我想进一步控制cirtain值的显示。
所以这是我的转发器:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource_MyList" EnableViewState="False">
<HeaderTemplate>
<table border="0" style="margin:0px; border-collapse: collapse; border-spacing: 0px; padding:0px;" class="table table-striped table-hover">
<thead>
<tr style="height:35px; font-weight: bold;">
<th style="width:20%" class="toprowcolor">StartNr</th>
<th style="width:40%" class="toprowcolor">Name</th>
<th style="width:30%" class="toprowcolor">StartDate</th>
<th style="width:10%" class="toprowcolor">Group</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr style="height:27px;" >
<td style="width:20%" class="listtext_s"><asp:Label ID="startnrLabel" runat="server" Text='<%# Eval("startnr") %>' /></td>
<td style="width:40%" class="listtext_s"><asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' /></td>
<td style="width:30%" class="listtext_s"><asp:Label ID="startdateLabel" runat="server" Text='<%# Eval("startdate", "{0:g}") %>' /></td>
<td style="width:10%" class="listtext_s"><asp:Label ID="groupLabel" runat="server" Text='<%# Eval("group") %>' /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
我想做这样的事情; (尝试用下面的代码解释我的目标,混合使用spegetticode(经典ASP)和一些转换到ASP.NET C#)我希望你能读懂它!?
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource_MyList" EnableViewState="False">
<HeaderTemplate>
<table border="0" style="margin:0px; border-collapse: collapse; border-spacing: 0px; padding:0px;" class="table table-striped table-hover">
<thead>
<tr style="height:35px; font-weight: bold;">
<th style="width:20%" class="toprowcolor">StartNr</th>
<th style="width:40%" class="toprowcolor">Name</th>
<th style="width:30%" class="toprowcolor">StartDate</th>
<th style="width:10%" class="toprowcolor">Group</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<% If Eval("name") == "aron"
{
If Eval("group") == "1"
{ namecellcolor = "#454545" }
ElseIf Eval("group") == "2"
{ namecellcolor = "#555555" }
ElseIf Eval("group") == "3"
{ namecellcolor = "#666666" }
Else
{ namecellcolor = "#FFFFFF" }
}
ElseIf Eval("name") == "bill"
{ namecellcolor = "#000000" }
Else
{ namecellcolor = "#111111" }
%>
<% If Eval("startdate", "{0:g}") <= DateTime.Now.Date; AND Eval("group") == "1" OR Eval("startdate", "{0:g}") <= DateTime.Now.Date; AND Eval("group") == "2"
{ groupcellcolor = "#010101" }
elseif Eval("startdate", "{0:g}") <= (DateTime.Now.Date; + 2) AND Eval("group") == "1" OR Eval("startdate", "{0:g}") <= (DateTime.Now.Date; + 2) AND Eval("group") == "2"
{ groupcellcolor = "#333333" }
else
{ groupcellcolor = "#000000" }
%>
<tr style="height:27px;" >
<td style="width:20%; background-color: <%# namecellcolor %>" class="listtext_s"><asp:Label ID="startnrLabel" runat="server" Text='<%# Eval("startnr") %>' /></td>
<td style="width:40%" class="listtext_s"><asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' /></td>
<td style="width:30%" class="listtext_s"><asp:Label ID="startdateLabel" runat="server" Text='<%# Eval("startdate", "{0:g}") %>' /></td>
<td style="width:10%; background-color: <%# groupcellcolor %>" class="listtext_s"><asp:Label ID="groupLabel" runat="server" Text='<%# Eval("group") %>' /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
你的回答:
那会是什么?
我非常感谢能得到的任何帮助。