Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is my code
this is my view page
C#
@Html.DropDownListFor(model => model.Day, listItems, "Day",new {@Id="ddlDay", style = "width: 70px;" })
              @Html.DropDownListFor(model=>model.Month, listItemsMonth,"Month",new{@Id="ddlMonth",style = "width: 90px;"})
              @Html.DropDownList("Years", new SelectList(ViewBag.Years as System.Collections.IEnumerable, Model.Year), new {@Id="ddlYear",style = "width: 70px;" })



this is my model

SQL
public DateTime Day { get; set; }
       public DateTime Month { get; set; }
       public DateTime Year { get; set; }
       public DateTime DateofBirth { get; set; }

this my controller
XML
public ActionResult AddUsers()
        {
            }

My db i have column as Datetime
Posted

1 solution

in controller use

C#
var newDate=new Datetime(Year.Year ,Month.Month,DateofBirth.Day)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900