Ich versuche, die Ausgabe von einem Repeater zu steuern.Wenn dann noch im Repeater
Ich habe eine schöne Arbeit Repeater aber möchte die Anzeige von cirtain Werte weiter steuern.
Das ist also mein Repeater:
<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>
Ich mag würde, so etwas tun; (Versuchen Sie, mein Ziel in unten Code mit einer Mischung aus Spegetticode (Classic ASP) mit einigen Übersetzungen zu ASP.NET C# zu erklären) Ich hoffe, Sie können es lesen !?
<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>
Ihre Antwort:
- Wow Geck, unter diesem Stonedge Block von Ihnen zurückkriechen und Mühe Dont zurück zu kommen!
- Interessante Reihe von Tippfehler haben Sie dort Champion!
- Ich werde versuchen, eine funktionierende Lösung für Ihr Problem zu erklären, und hier geht es;
Also was wird es sein?
Ich schätze wirklich jede Hilfe, die ich bekommen kann.
stets getrennt Stil von Markup und server Code, einfach erstellen Klassen für Ihren Bedarf. –
Warum können Sie den Datensatz nicht ändern, bevor Sie ihn an den Repeater binden? –
Genau, warum kann ich den Datensatz nicht ändern, bevor er an den Repeater gebunden wird? Wenn ich kann, ist die Frage eher wie? – Slint