Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i'm currently working on asp.net-mvc project for which i need to display available time in dropdownlist for the date that has been selected to the user. i'm using full calendar to display the date. Available time is store in the database. This is my view
HTML
@Html.LabelFor(model => model.date, htmlAttributes: new { @class = "control-label col-md-2" })
            
                @Html.EditorFor(model => model.date, new { htmlAttributes = new { @class = "form-control", id = "datepicker" } })
                @Html.ValidationMessageFor(model => model.date, "", new { @class = "text-danger" })
            
        

 
                @Html.LabelFor(model => model.time, htmlAttributes: new { @class = "control-label col-md-2" })
                
                    @Html.DropDownList("time", null, "--Select Time--", htmlAttributes: new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.time, "", new { @class = "text-danger" })

this is my controller

C#
public ActionResult CreateBooking()
    {

        return View();

    }

    // POST: Booking/Create

    [HttpPost]

    public ActionResult CreateBooking(bookingPatient bo)

    {

        try

        {

            b.booking(bo);

            System.Web.HttpContext.Current.Session["date"] = bo.date;

            return RedirectToAction("Index", "Booking");


        }

        catch

        {

            return View();

        }

    }


this is my business class


C#
public void booking(bookingPatient model)
    {
        using (var bookpro = new BookingRepository())
        {
            if (model.BookingId == 0)
            {
                Booking _booking = new Booking
                {
                    Date = model.date,
                    Time = model.time                        
                };
                bookpro.Insert(_booking);
                System.Web.HttpContext.Current.Session["bookingId"] = _booking.BookingId;
            }
        }
    }



this is my modelview

C#
public class bookingPatient
{
    public int id { get; set; }
    public DateTime date{ get; set; }
    public DateTime time { get; set; }
}


Someone please guide me in this regard. Thanks in advance
Posted

1 solution

ByMeans of Culture Info You can get the date and time as per your requirement.
https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).aspx[^]
 
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