I am having 2 textboxes and applied timepickers. Here I am leaving textboxes to null i.e not giving any date and sending to db as a fromdate and todate parameters. in msql storedprocedure if Fromdate and todate are empty, one action is performed.inorder to do that task I have taken 2 variables
DateTime fromdate;
DateTime todate;
and declared as a Datetime in codebehind.
fromdate = Convert.ToDateTime(txtfromdate.Text);
todate = Convert.ToDateTime(txttodate.Text);
When I am sending to db
fromdate = Convert.ToDateTime(txtfromdate.Text);
todate = Convert.ToDateTime(txttodate.Text);
it is getting error.formate exception. Is it possible to apply null to datetime variables?