Hide previous dates record in RDLC Report in ASP.Net

kankon
 
on Jul 22, 2020 11:32 PM
1212 Views

Hello,

am follwing this Load RDLC Report using Report Viewer programmatically in ASP.Net using C# and VB.Net

i would like to hide old date only show new or next days

namespace gsc
{
    public partial class managerviewe : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/managerreport.rdlc");
                DataSet1 dsCustomers = GetData("SELECT id, date, metting, whiwhois, location, time, note FROM dbo.Manager");
                ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables["Manager"]);
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(datasource);
            }
        }

        private DataSet1 GetData(string query)
        {
            string conString = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
            SqlCommand cmd = new SqlCommand(query);
            using (SqlConnection con = new SqlConnection(conString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection = con;

                    sda.SelectCommand = cmd;
                    using (DataSet1 dsCustomers = new DataSet1())
                    {
                        sda.Fill(dsCustomers, "Manager");
                        return dsCustomers;
                    }
                }
            }
        }
    }
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 23, 2020 12:46 AM

Hi kankon,

In order to hide the old date data you need to add where condition to filter with date greater than equals to todats date in the select statement. 

DataSet1 dsCustomers = GetData("SELECT id, date, metting, whiwhois, location, time, note FROM dbo.Manager");

 Replace above with below.

DataSet1 dsCustomers = GetData("SELECT id, date, metting, whiwhois, location, time, note FROM dbo.Manager WHERE date >= CAST(GETDATE() AS DATE)");