我有一个转发器,只有经理才能看到,他们可以接受/拒绝用户提出的请假。
以下代码在绑定我的转发器时,会检查是否有任何正在休假的员工在同一部门工作并且与用户请求的相同日期。
protected void RptLeaveRequests_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
otherEmpsLeave = new LeaveLogic().CheckEmployeeLeaveOnDateInSameDep(date, currEmp);
if (otherEmpsLeave != "")
{
//change border of repeater row to another colour and display otherEmpsLeave when manager hovers on repeater row
}
}
如何更改转发器行边框颜色(例如,添加红色边框以使其突出显示)并在悬停时显示otherEmpsLeave
?
ASP转发器代码:
<h3>LEAVE REQUESTS</h3>
<asp:Label ID="LblNoRequests" Visible="false" Font-Size="14px" runat="server"></asp:Label>
<asp:HiddenField ID="dataGroups" runat="server" />
<asp:Repeater ID="RptLeaveRequests" runat="server"
onitemdatabound="RptLeaveRequests_ItemDataBound">
<ItemTemplate>
<table id="tableItem" runat="server">
<tr>
<td style="width:400px;">
<asp:Label ID="lblEmployeeId" runat="server" Text='<%#Eval("EmployeeId") %>' Visible="false" />
<asp:HiddenField ID="HdnEmployeeId" runat="server" Value='<%#Eval("EmployeeId") %>' />
<asp:Literal Text="" runat="server" ID="LiteralUser" ></asp:Literal>
</td>
</tr>
<tr>
<td style="width: 100px;">
<asp:HiddenField ID="HdnRequestId" runat="server" Value='<%#Eval("id") %>' />
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date", "{0:dd/MM/yyyy}") %>'></asp:Label>
</td>
<td style="width: 80px;">
<asp:Label ID="lblHours" runat="server" Text='<%#Eval("Hours") %>'></asp:Label>
</td>
<td style="width: 50px; font-size:10px;">
<asp:Label ID="lblPeriod" runat="server" Text='<%#Eval("AMorPM") %>'></asp:Label>
</td>
<td style="width: 850px; font-size:10px;">
<asp:Label ID="lblNote" runat="server" Text='<%#Eval("Note") %>'></asp:Label>
</td>
<td style="width: 50px;">
<asp:RadioButtonList ID="rbtVerified" runat="server" Visible='<%#!(Boolean)Eval("ReadOnly") %>' >
<asp:ListItem Value="1">Accept</asp:ListItem>
<asp:ListItem Value="2">Reject</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:TextBox ID="txtNotes" runat="server" ></asp:TextBox>
</td>
</tr>
</table>
<div style="border-style: dotted; border-color:Black; width:100%; border-width:1px; border-color:#999999"></div>
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:2)
从MSDN示例中,类似
void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
// This event is raised for the header, the footer, separators, and items.
// Execute the following logic for Items and Alternating Items.
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
if (((Evaluation)e.Item.DataItem).Rating == "Good") {
((Label)e.Item.FindControl("RatingLabel")).Text= "<b>***Good***</b>";
}
}
}
而不是设置.Text设置您需要的任何属性,例如背景或工具提示