I am trying to find out which event i should put my code that would normally be placed in .aspx. To be precise:
Normally i can write something like
<asp:DropDownList ID="lst1" runat="server">
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
</asp:DropDownList>
to populate my dropdownlist.
But i want this list to populate in my code behind class. I am trying to figure out which event like “On_Init”, “On_Prerender” is best place to put the code so that it has same effect as above.
I am trying to use following code in my code behind class:
for int i=5; i<=9; i++
{
lst1.items.add(i)
}
Thanks
CSS
I think the best place is on Page_Load method! But it depends most from your application architecture!