Filling Up DropDown in Page Load
<p>I'm trying to fill up my dropdown menu by a series of queries that I make, automatically whenever the page loads. Whenever I choose a value in the dropdown and I press a button, it goes back to the first index, so I'd like to know if there is anyway to prevent this problem:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    Functions.username = "1"; // This is just to get rid of my login screen for testing puposes
    DropDownList1.Items.Clear();

    Functions.moduledatelister();
    for (int i = 0; i &lt;= Functions.moduledatelist.Count-1; i++) {
    DropDownList1.Items.Add(Functions.moduledatelist.ElementAt(i));
    }

}

protected void Button2_Click(object sender, EventArgs e)
{
    Label1.Text = Functions.DATES.ElementAt(DropDownList1.SelectedIndex).ToString();
}
</code></pre>

<p>after the button is pressed the index goes back to 0 and the label shows the value for the first item.</p>
