Link to home
Start Free TrialLog in
Avatar of Shepwedd
Shepwedd

asked on

How do I show uk date formats in the asp.net ReportViewer control?

I have written a C# website using visual studio 2008. I have created a dataset which is filled by the results of a stored procedure. I am then using an objectdatasource bound to a reportviewer control to show the data in my dataset which is filtered on two user input textbox controls that have datetime values attached to them. The attached code is what I have written to filter the data in my dataset behind a button click event on my frontend. At the moment the date data is shown in the reportviewer with a time attached to it where I only want to show the date and the date is shown in US format, i.e. 4/14/2009 instead of 14/4/2009? Can anyone help?

Thanks.
protected void CrucialDatesReportButton_Click(object sender, EventArgs e)
    {
        ReportViewer1.Visible = true;
        SqlConnection thisConnection = new SqlConnection(thisConnectionString);
        SqlCommand cmd = new SqlCommand("CrucialDates.proc_ShowCrucialByDate", thisConnection);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        System.Data.DataSet thisDataSet = new System.Data.DataSet();
        SqlParameter crucialDueDateFromParameter = new SqlParameter("@DueDateFrom", SqlDbType.DateTime);
        SqlParameter crucialDueDateToParameter = new SqlParameter("@DueDateTo", SqlDbType.DateTime);
        crucialDueDateFromParameter.Direction = ParameterDirection.Input;
        crucialDueDateFromParameter.Value = tbCrucialSearchDateFrom.Text;
        cmd.Parameters.Add(crucialDueDateFromParameter);
        crucialDueDateToParameter.Direction = ParameterDirection.Input;
        crucialDueDateToParameter.Value = tbCrucialSearchDateTo.Text;
        cmd.Parameters.Add(crucialDueDateToParameter);
        da.Fill(thisDataSet);
 
        ReportDataSource datasource = new ReportDataSource("CrucialDatesDataSet_proc_ShowCrucialByDate", thisDataSet.Tables[0]);
 
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);
        if (thisDataSet.Tables[0].Rows.Count == 0)
        {
            lblMessage.Text = "No Crucial Dates are due!";
        }
 
        ReportViewer1.LocalReport.Refresh();
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GuitarRich
GuitarRich
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
See code snippet.
It formats the currentdate, but you can enter your own ofcourse.


currentDate = Format(Now, "dd/MM/yyyy")

Open in new window

Avatar of Shepwedd
Shepwedd

ASKER

Thanks.