简体   繁体   English

通过代码更改中继器边框颜色

[英]Change repeater border colour through code

I have a repeater which is visible only by managers where they can accept/reject leave requests made by the users. 我有一个中继器,只有管理员可以看到/接受该中继器,他们可以接受/拒绝用户提出的请假请求。

The following code while binding my repeater, retrieves if there are any employees on leave working in the same department and on the same date as the one requested by the user. 绑定我的中继器时,以下代码检索是否有与用户要求的员工在同一部门和同一日期工作的请假员工。

 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
     }
 }

How can I change repeater row border colour (ex add a red border to make it stand out) and display otherEmpsLeave on hover? 如何更改中继器行边框的颜色(例如添加红色边框以使其突出)并在悬停时显示otherEmpsLeave

ASP Repeater Code: 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>

From the MSDN example, something like 在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>";
         }
      }
   } 

instead of setting .Text set whatever property(s) you need, such as Background or Tooltip 而不是设置.Text设置所需的任何属性,例如Background或Tooltip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM