Basic Example to fill DropdownList i.e. Case of filling years

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 371
Basic Example to fill DropdownList i.e. Case of filling years


ASP code

  <asp:DropDownList ID="ddlLPRYear" runat="server" Width="60px" >
</asp:DropDownList>



c# code
 int j = 1990;
ddlLPFXYear.Items.Clear();
for (; j <= 2020; j++)
{
ddlLPFXYear.Items.Add(j.ToString());
}
j = DateTime.Now.Year;
ddlLPFXYear.SelectedIndex = ddlLPFXYear.Items.IndexOf(ddlLPFXYear.Items.FindByValue(j.ToString()));


Thanks
Amatya

Comments or Responses

Login to post response