none
Higlight new record in asp.net RRS feed

  • Question

  • i use repeater in my project .. so when user add new document then i want to highlight new add documents same as gmail when we see new email in gmail account then email is in bold and then we able to see someone send email same as i want when new record added then how to highlight or identify in other ways? this is repeater code..

      <table class="CSSTableGenerator" border="0"  cellpadding="0" cellspacing="0" id="results">
                            <asp:Repeater ID="Repeater2" OnItemCommand="Repeater2_ItemCommand"   
                                runat="server" onitemdatabound="Repeater2_ItemDataBound">
                                <HeaderTemplate>
                                    <tr>
                                        
                                       <%-- <td>
                                           DocumentID
                                        </td>--%>
                                        <td>
                                           Document Name
                                        </td>
                                        <td>
                                            File Name
                                        </td>
                                        <td>
                                           Uploaded By
                                        </td>
                                        <td>
                                           Uploaded Date
                                        </td>
                                        <td>
                                            Email
                                        </td>
                                       
                                        <td>
                                            Department
                                        </td>
                                        <td>
                                            Status
                                        
                                        </td>
                                       
                                    </tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr>
                                       
                                        
                                        <asp:HiddenField ID="DocId" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "DocID")%>' />
    <%--                                    <asp:Label Id="DocId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DocID")%>'></asp:Label>
    --%>                                    
                                        <td>
                                        <asp:Label Id="DocName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DocumentName")%>'></asp:Label>
                                        </td>
                                        <td>
                                        <asp:Label Id="Uploadfile" runat="server"  Text='<%#DataBinder.Eval(Container.DataItem, "Uploadfile")%>'></asp:Label>
                                        </td>
                                         <td>
                                        <asp:Label Id="Label1" runat="server"  Text='<%#DataBinder.Eval(Container.DataItem, "UploadedBy")%>'></asp:Label>
                                        </td>
                                        <td>
                                        <asp:Label Id="UploadedDate" runat="server"  Text='<%#DataBinder.Eval(Container.DataItem, "UploadedDate")%>'></asp:Label>
                                        </td>
                                         <td>
                                        <asp:Label Id="YourEamil" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "UserEmail")%>'></asp:Label>
                                        </td>
                                        
                                        <td>
                                        <asp:Label Id="DepType" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Department")%>'></asp:Label>
                                        </td>
                                        
                                       
                                    <td>
                                
                                
                                 <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("ApproveID") %>' Visible = "false" />
                                  <asp:HiddenField ID="hfDepartmentId" runat="server" Value='<%# Eval("ApproveID") %>' />


                            <asp:DropDownList ID="DropDownList4" runat="server" EnableViewState="true" class="vpb_dropdown1" DataTextField="ApproveType" DataValueField="ApproveID" AutoPostBack="true" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
                                 <asp:ListItem Text="Pending" selected="selected" Value="3"></asp:ListItem>
                                 <asp:ListItem Text="Approve" Value="1"></asp:ListItem>
                                 <asp:ListItem Text="Reject" Value="2"></asp:ListItem>
                            </asp:DropDownList>
                            </td>
                            </tr>
                            </ItemTemplate>
                                </asp:Repeater>
                                </table>
                                      
                     
                     <asp:Label ID="Supvisor" runat="server" Font-Size="Medium" ForeColor="Red" ></asp:Label><br />
                     <asp:Label ID="Successz" runat="server" Font-Size="Medium" ForeColor="Green" ></asp:Label><br />

                <asp:Button ID="Button1" runat="server"   Text="Submit" onclick="Button1_Click" />

    someone suggest use flag for this ..but i dont know how i use it in sql and also in vs

    i add new column in table e.g

    column name datatype

    yes-no       bit

    and i create this sp

     SELECT dbo.DocumentInfo.DocID, dbo.DocumentInfo.DocName as DocumentName,
     dbo.DocumentInfo.Uploadfile,
     dbo.DocumentInfo.UploadedBy as UploadedBy,
     dbo.DocumentInfo.UploadedDate as UploadedDate,
     dbo.Userss.Email as UserEmail,
      dbo.Department.DepType as Department ,
      
     dbo.Designation.DesigType,
      dbo.ApproveType.ApproveType AS ApproveID
      FROM dbo.Department
      left JOIN dbo.DocumentInfo
      ON dbo.DocumentInfo.DepID=dbo.Department.DepID 
    
    
      left JOIN dbo.DocType
      ON  dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
        inner JOIN dbo.Userss on Userss.UserName =dbo.DocumentInfo.UploadedBy 
         
     inner join dbo.Designation on dbo.Designation.DesigID=dbo.Userss.DesigID
       LEFT JOIN dbo.ApproveType
        ON dbo.ApproveType.approveid=dbo.Department.DepID
        where dbo.Department.DepID=@DepID  AND dbo.Designation.DesigType !='Supervisor'

    Thursday, January 23, 2014 2:12 PM

Answers

  • Hi,

    It seems to be asp.net forum issue. But there is a suggestion that You can add a field which detect which row is unreaded or new record and then set style according to the field value. like this code below:

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
    
    
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                foreach (Control c in e.Item.Controls)
                {
                    if (c is System.Web.UI.HtmlControls.HtmlTableRow)
                    {             
                        HtmlTableRow tr = (HtmlTableRow)c;
                        foreach (Control c1 in tr.Controls)
                        {
                            Label mylabel = (Label)c1.FindControl("lblprice");
                            if (mylabel != null)
                            {
                                if (Convert.ToDecimal(mylabel.Text) >20)
                                {
                                    tr.BgColor = System.Drawing.Color.Red;                            }
                                 }
                             }
                         }
                    }
                }
        }

    For more information, you can refer here

    http://forums.asp.net/t/1181871.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Pengzhen Song Wednesday, February 5, 2014 3:01 AM
    Friday, January 24, 2014 3:09 AM