Search This Blog

Wednesday, October 27, 2010

Create Dropdown List For Year in C#

code for create LI one object for showing year with increment.

#region BINDYEAR
    private void BINDYEAR()
    {
        try
        {
            int A = 1800;
            for (int i = 0; i < 20; i++)
            {
                ListItem LI = new ListItem();
                LI.Text = Convert.ToInt16(A).ToString();
                LI.Value = A.ToString();
                A=A+1;
                ddl_year.Items.Add(LI);
            }
            ddl_year.Items.Insert(0, "YYYY");
              
        }
        catch (Exception errmsg)
        {
            Response.Write(errmsg.Message.ToString());
        }
    }
    #endregion