Click here to Skip to main content
15,889,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i've search on the interned on how to hide the cell on the gridview but my problem is how to auto hide the data on the gridview after 24hours

Can anyone help me on how to hide the data after 24 hours

What I have tried:

Here's my code to display the gridview and the data
C#
DataTable dt = new DataTable();

            dt.Columns.Add("Subject", typeof(string));
            dt.Columns.Add("Sender", typeof(string));
            dt.Columns.Add("DateCreated", typeof(string));
            dt.Columns.Add("EmailHeader", typeof(string));

            foreach (Item item in email.EmailList)
            {
                dt.Rows.Add(item.Subject, item.DisplayTo, item.DateTimeCreated, item.Body);

                GridView1.DataSource = dt;
                GridView1.DataBind();
  
            }


and here's the gridview
ASP.NET
<pre>  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowCommand="GridView1_RowCommand" Height="423px">
            <Columns>
                <asp:BoundField DataField="DateCreated" HeaderText="Date and Time" />
                <asp:TemplateField HeaderText="Receiver">
                    <ItemTemplate>
                       <asp:LinkButton runat="server" CommandArgument='<%# Eval("Sender") %>' Text='<%# Eval("Sender") %>'></asp:LinkButton> <%--OnClientClick="document.getElementById('id01').style.display='block'; return false"--%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Subject" HeaderText="Email Error" />
                
                <asp:TemplateField HeaderText="Email Body">
                    <ItemTemplate>
                       <asp:Button ID="txtItemBody"  runat="server" Text='<%# Eval("EmailHeader") %>' Width="100px" Enabled="false"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="View Email ">
                    <ItemTemplate>
                       <asp:Button runat="server"  CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" Text="View Email" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
            <RowStyle BackColor="whitesmoke" ForeColor="#0a0014" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#0a0014" />
            <SortedAscendingCellStyle BackColor="#FEFCEB" />
            <SortedAscendingHeaderStyle BackColor="#AF0101" />
            <SortedDescendingCellStyle BackColor="#F6F0C0" />
            <SortedDescendingHeaderStyle BackColor="#7E0000" />
        </asp:GridView>
Posted
Updated 1-Jan-18 10:17am
v2
Comments
Karthik_Mahalingam 2-Jan-18 1:21am    
so until next 24 hours the page will not get refreshed?
what is the business logic?
Member 13427032 3-Jan-18 7:47am    
i set that the page will refresh every 1 min for the new bounce back email will appear on the gridview and I want to to have on my program that the file will appear only for 24 hours and after that the file will automatic hide on the gridview. Thanks

1 solution

Remove it from the data source the grid is bound to on the next page refresh. Refresh the page as appropriate for your business rules.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900