About add the numbers to the Drop down form 0 to 99

Last post 07-11-2009 5:13 AM by mohd786hussain. 2 replies.

Sort Posts:

  • About add the numbers to the Drop down form 0 to 99

    07-11-2009, 1:35 AM

    Dear all,

    For the Drop down i need to  add the 0 to 99 numbers suppose if we add the numbers through hard code unnssesarily performance become low so i need to add the 0 to 99 numbers dynamically to the drop down plz help me:) 

  • Re: About add the numbers to the Drop down form 0 to 99

    07-11-2009, 5:09 AM
    Answer
    • Participant
      1,311 point Participant
    • rushik
    • Member since 02-27-2009, 1:15 PM
    • Ahmedabad
    • Posts 236

    You can loop from 0 to 99 if you donot want to add it hardcode.

    ListItem li;
    
    for (int i = 0; i < 100; i++)
            {
                li = new ListItem(i.ToString(), i.ToString());
                DropDownList1.Items.Add(li);
            }
    DropDownList1.DataBind();

     

    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !
    ---------
    Rushik
  • Re: About add the numbers to the Drop down form 0 to 99

    07-11-2009, 5:13 AM
    Answer

    Hi,

    put a simple drop down page and in page load event write the following code and you are done.

    for(int i=0;i<99;i++)

    {

    dropdownid.item.insert(i, new ListItem(i, i);

    }

    Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
    Mohammad Hussain
    http://mohdhussain.blogspot.com/
Page 1 of 1 (3 items)