How to added in this items

Posted by Jayakumars under C# on 6/13/2017 | Points: 10 | Views : 248 | Status : [Member] [MVP] | Replies : 1
Hi

How to add Hrs,sec,am and pm in Dropdownlist in MVC5

I need like this Dropdownlist 5 min intervals

09:00 AM
09:05 AM
etc
09:00 PM

how to create this list and assign Dropdownlist mvc5

Mark as Answer if its helpful to you


Responses

Posted by: Qyam on: 6/14/2017 [Member] Starter | Points: 25

Up
0
Down

Follow the below steps.

1. Create a table as below and insert above time interval values into it.
create table IntervalDetails
int id identity(1,1),
interval varchar(10)

2. create a model for the newly created table.
Public class ABC
{
public int id {get;set;},
publice string interval {get;set;}
}

3. Create a controller method to get intervals details from db and store into list.
public void LoadInterval()
{

List<ABC> li = new List<ABC>();
--fetch record from db and loop through all items and store into the list. Now pass list to view using viewdata.
ViewData["xyz"] = li;
}

4. Bind drop down

@Html.DropDownList("timeintervals", ViewData["xyz"] as List<ABC>)

hope it helps.

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response