问题
I am using DevXpress XtraReport v13.1
I have a dateTime parameter that I would like its default value to be current Day whenever it is used. When I leave the value of the parameter empty. it is understood by DevExpress as 1/1/0001 !!!
It is important for me because the parameters will be applied as a filter to a database and I require to decrease the probability that user can fetch too much data from the database (that may affect the performance)
Anyone have an idea of how to do that?
回答1:
I just did It Like this
public Report()
{
InitializeComponent();
this.Parameters[0].Value = DateTime.Today;
this.Parameters[1].Value = DateTime.Today;
}
the Approach AbdelRahman Shabana took Fails because the Event fires Again when user Clicks Submit, Just Give A look Here
回答2:
Thanks for all who gave me hints. I managed to solve my problem programatically by responding to event : ParameterRequestBeforeShow Then the report will be shown with today's date as default value for parameters and user is still allowed to select different date.
private void XtraReport1_ParametersRequestBeforeShow(object sender, DevExpress.XtraReports.Parameters.ParametersRequestEventArgs e)
{
this.Parameters["StartIssueDate"].Value = DateTime.Now;
this.Parameters["EndIssueDate"].Value = DateTime.Now;
}
回答3:
There is a discussion with a solution in the DevExpress Support Center.
One of those solutions is to create your parameter as a nullable DateTime?
but then it is more complicated to bind to the XRControl
.
来源:https://stackoverflow.com/questions/18635285/devexpress-xtrareport-setting-a-datetime-parameter-to-today