Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:54:23+00:00 2026-06-15T14:54:23+00:00

I have a requirement to populate 2 drop down list with hours and minutes.

  • 0

I have a requirement to populate 2 drop down list with hours and minutes. My current method of populating the drop downs doesn’t format the numbers correctly as I require the leading 0 for the first 9 number i.e 01,02,03 not 1,2,3 as is currently happening.

C#

protected override void OnInit(EventArgs e)
{
  base.OnInit(e);
  if (!IsPostBack)
     {
        // Populate and Bind Time drop downs
        ddlOh1OpenHours.DataSource = Enumerable.Range(00, 24);
        ddlOh1OpenHours.DataBind();
        ddlOh1OpenMinutes.DataSource = Enumerable.Range(00, 60);
        ddlOh1OpenMinutes.DataBind();
      }
}

ASPX

<asp:DropDownList ID="ddlOh1OpenHours" runat="server" />
<span>:</span>
<asp:DropDownList ID="ddlOh1OpenMinutes" runat="server" />

Result:

<select name="ctl00$MainContent$ddlOh1OpenHours" id="ctl00_MainContent_ddlOh1OpenHours">
    <option selected="selected" value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
</select>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:54:24+00:00Added an answer on June 15, 2026 at 2:54 pm

    Just use ToString with the proper format:

    var hours = Enumerable.Range(00, 24).Select(i => i.ToString("D2"));
    var minutes  = Enumerable.Range(00, 60).Select(i => i.ToString("D2"));
    
    dlOh1OpenHours.DataSource = hours;
    ddlOh1OpenHours.DataBind();
    ddlOh1OpenMinutes.DataSource = minutes;
    ddlOh1OpenMinutes.DataBind();
    

    > Demo <

    Standard Numeric Format Strings

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement where I can use JS Fiddle dropdown to populate States
I have requirement to get Facebook friends list with their images. How can I
There is a requirement to have not-so-trivial dynamic list, each record of which consists
We have a requirement to populate a master table which consists of columns from
I have a requirement where i have to populate values in a PDF Form
I have the following in my controller. My requirement is to populate the second
On my page I have a drop down whose values are populated based on
I have the requirement in a Flex application to create & populate an object
I have requirement where some times I would like to load children as well
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.