Hi
private void BindTime() { DateTime StartTime = DateTime.ParseExact("08:00", "HH:mm", null); DateTime EndTime = DateTime.ParseExact("20:00", "HH:mm", null); TimeSpan Interval = new TimeSpan(0, 15, 0); //TimeSpan Interval = new TimeSpan(1, 0, 0); ddlTimeFrom.Items.Clear(); ddlTimeTo.Items.Clear(); while (StartTime <= EndTime) { ddlTimeFrom.Items.Add(StartTime.ToShortTimeString()); ddlTimeTo.Items.Add(StartTime.ToShortTimeString()); StartTime = StartTime.Add(Interval); } ddlTimeFrom.Items.Insert(0, new ListItem("--Select--", "0")); ddlTimeTo.Items.Insert(0, new ListItem("--Select--", "0")); }
String frTime = ddlTimeFrom.SelectedItem.Value; var frts = TimeSpan.Parse(frTime); String toTime = ddlTimeTo.SelectedItem.Value; var tots = TimeSpan.Parse(toTime);
But it is saving in Database like this - 08:30:00.0000000
Field Datatype is Time(7)
Also how to get saved value in Dropdown.
Thanks