Solved

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

Posted on 2009-05-08
3
504 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:Shepwedd
3 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
Comment Utility
In the report file the textbox holding the dates should have a Format property - set this to dd/MM/yyyy
0
 
LVL 5

Expert Comment

by:karstieman
Comment Utility
See code snippet.
It formats the currentdate, but you can enter your own ofcourse.


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

Open in new window

0
 

Author Closing Comment

by:Shepwedd
Comment Utility
Thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now