mvc – c# – aspx =>
i have a DDL(drop down list), that shows the dates from a table, the DDL is used for filtering items shown in a table. the table works, the filters work, the only ugly thing is that the filter shows a time with the date : 02/12/2010 12:00:00:00:00AM or something like that, i am trying to drop the time as it comes form the table, but if there is a better way please help,
i have tried the following: in the controller => string.format :tells me that its not a valid sql what ever….ToString(“MM/dd/yyyy”, n) tells me the same, i also tried convert(varchar(12), n, 101) thinking that it might take the sql server but it didnt like that either, i even tried to add a format to the DDL key in the view file, and as i expected it said it could not find whatever with that key.
// target date -- this code is from my controller
if ((Request.Form["TARGET_DATE"] != null) && Request.Form["TARGET_DATE"] != "")
{
TargetDate = Request.Form["TARGET_DATE"];
ViewData["TARGET_DATE"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "TARGET_DATE", "TARGET_DATE", TargetDate);
predicate = predicate.And(p => p.TARGET_DATE == Convert.ToDateTime(TargetDate));
}
else
{
TargetDate = null;
ViewData["TARGET_DATE"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "TARGET_DATE", "TARGET_DATE");
}
is there any way to format the ‘n’ to follow ‘MM/dd/yyyy’? or how would be the best way to do this? or what am i doing wrong? …..thank you
thanks every one that helped… i was finally able to get the date to show without the time in my dropdownlist(DDL). this is how i did it.
i hope that this also helps other people that were having the same issue.