[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2009-05-08
3
Medium Priority
?
511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 2000 total points
ID: 24336309
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
ID: 24336378
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
ID: 31579442
Thanks.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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