Last post Feb 06, 2020 05:52 AM by Yongqing Yu
Feb 05, 2020 10:47 AM|Programming and Design|LINK
I have one CheckboxList in my page and I want to bind next 7 days (not today) value in my list dynamically. The value should me inserted in the format as shown in image below right side and when I display the page in aspx I
want to display Date and Day as shown in the 1st image format.
<asp:CheckBoxList ID="CheckBoxList1" runat="server"></asp:CheckBoxList>
Feb 05, 2020 02:50 PM|mgebhard|LINK
Use a custom date format string. I think you'll be interested in reading the date format docs as they cover how to format dates in detail.
The best I can do for you are this point is provide the format string to use. You did not share the actual code that populates the CheckBoxList so you'll need to add the format string yourself. You should be able to figure that out on your own though.
static void Main(string args)
DateTime now = DateTime.Now;
Feb 06, 2020 05:52 AM|Yongqing Yu|LINK
Hi Programming ,
As @megard said, you can convert datetime data to the format you want to display by using ToString("dddd yyyy-MM-dd") .
Below I created a case based on your needs, you can refer to it:
protected void Page_Load(object sender, EventArgs e)
DateTime today = DateTime.Now;
List<string> dateTimes = new List<string>();
for (int i = 1; i <= 7; i++)
CheckBoxList1.DataSource = dateTimes;
Here is the result :