How to get the current week starting date and add it to a combo box?

前端 未结 4 1586
不知归路
不知归路 2021-02-14 10:17

I\'m attempting to recreate a time sheet built on asp and I can\'t figure out how to get the current weeks starting date \"6-13-2010\" and have it populate a combo box can you h

4条回答
  •  执念已碎
    2021-02-14 10:26

    DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));
    

    Regarding adding items to a DropDownList in ASP.NET, assuming you're using the webforms model, you would do something like

    yourDropDown.Items.Add(new ListItem(yourText, yourValue));
    

提交回复
热议问题