Click here to Skip to main content
13,793,266 members
Rate this:
Please Sign up or sign in to vote.
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
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;

and here's the gridview
<pre>  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowCommand="GridView1_RowCommand" Height="423px">
                <asp:BoundField DataField="DateCreated" HeaderText="Date and Time" />
                <asp:TemplateField HeaderText="Receiver">
                       <asp:LinkButton runat="server" CommandArgument='<%# Eval("Sender") %>' Text='<%# Eval("Sender") %>'></asp:LinkButton> <%--OnClientClick="document.getElementById('id01').style.display='block'; return false"--%>
                <asp:BoundField DataField="Subject" HeaderText="Email Error" />
                <asp:TemplateField HeaderText="Email Body">
                       <asp:Button ID="txtItemBody"  runat="server" Text='<%# Eval("EmailHeader") %>' Width="100px" Enabled="false"/>
                <asp:TemplateField HeaderText="View Email ">
                       <asp:Button runat="server"  CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" Text="View Email" />
            <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" />
Posted 1-Jan-18 10:37am
Updated 1-Jan-18 11:17am
Karthik Bangalore 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181207.3 | Last Updated 1 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100