I have a datetime picker that works for some specific date i.e 01-08-2019 to 12-08-2019. If i select a date outside that range (at least I tried about 20 other different dates) I get an error Please i need help with it.
I have tried changing the jquery code but it is the same.
c#
public ActionResult GetTransactions(string terminal, string branch, DateTime date) {
List < ATM_TRANSACTIONS > trans = null;
using(var context = new TestEntities2()) {
var query = from st in context.ATM_TRANSACTIONS
where st.branch_code == branch
where st.terminal_id == terminal
where st.transaction_date == date.Date
select st;
trans = query.ToList < ATM_TRANSACTIONS > ().ToList();
}
//var resp = Json(trans, JsonRequestBehavior.AllowGet);
//return resp;
//Transactions(trans);
ViewBag.trans = trans;
ViewBag.terminal = terminal;
ViewBag.branch = branch;
ViewBag.date = date;
return View();
}
html
<div class="col-xs-3">
<div class="box" id="box3">
<div class="box-header">
<div class="form-group">
<label for="TransactionDate">Transaction date</label>
@*<input type="date" id="trans_date" class="form-control datepicker" style="width: 100%;">*@
<div class="input-group date form-group">
<input type="text" id="t_date" name="date" class="form-control" value="@ViewBag.date"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
jquery
$('#t_date').datepicker({
format: "dd/mm/yyyy",
//keyboardNavigation: false,
//forceParse: false,
todayHighlight: true,
autoclose: true,
});
I am getting error message
The parameters dictionary contains a null entry for parameter 'date' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult GetTransactions(System.String, System.String, System.DateTime)' in 'XYZPortal.Controllers.AdminController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters