Using dropdownlist to auto populate page during pageload
<p>I'm new to asp.net and my title might be a bit confusing so let me explain, also I might be doing this the wrong way so if you have any suggestions that would be great.</p>

<p>When a user logs into my site they are given a dropdownlist of their client and site. They can have multiple clients or sites. Once they log in they are sent to a general dashboard displaying information about the site.</p>

<p>I made a user control for the the sitedrop down called Sitepicker which populates the 2 dropdown lists using a stored procedure. Many users only have 1 client and site, so I wanted it to auto select the first client and site that is populated in the dropdownlist and use that for the general dashboard.</p>

<p>This how I populate the sites dropdownlist.</p>

<pre><code>    void PopulateSiteList()
    {
            DataAccess da = new DataAccess();
            da.AddParameter("portaluserid", Page.User.Identity.Name, DataAccess.SQLDataType.SQLString, 256);
            da.AddParameter("ClientID", Session["ClientID"], DataAccess.SQLDataType.SQLInteger, 4);
            DataSet SiteList = da.runSPDataSet("Portal_SitePickerSiteList");

            DropDownListSite.DataSource = SiteList;
            DropDownListSite.DataValueField = "SiteID";
            DropDownListSite.DataTextField = "SiteName";
            DropDownListSite.DataBind();
    }
</code></pre>

<p>Here is the pageload of the sitepicker.</p>

<pre><code>    protected void Page_Load(object sender, EventArgs e)
    {   
        if (!IsPostBack)
        {       
            if (Session["ClientName"] != null)
                ClientButton.Text = Session["ClientName"].ToString();
            if (Session["SiteName"] != null)
                SiteButton.Text = Session["SiteName"].ToString();

            LoadClientDDL();

            if (DropDownListClient.Items.Count.Equals(1))
            {
                ClientButton.Enabled = false;
                DropDownListClient.Visible = false;
                int ClientID = int.Parse(DropDownListClient.SelectedItem.Value);
                ClientButton.Text = DropDownListClient.SelectedItem.Text;
                ClientButton.Visible = true;
                Session["ClientID"] = ClientID;
                Session["ClientName"] = DropDownListClient.SelectedItem.Text;

                {
                    PopulateSiteList();

                }

                if (DropDownListSite.Items.Count &gt; 0)

                {
                    DropDownListSite.SelectedIndex = 1;
                    DropDownListSite.Visible = false;
                    SiteButton.Visible = true;
                    int SiteID = int.Parse(DropDownListSite.SelectedItem.Value);
                    SiteButton.Text = DropDownListSite.SelectedItem.Text;

                    Session["SiteID"] = SiteID;
                    Session["SiteName"] = DropDownListSite.SelectedItem.Text;

                }
            }
</code></pre>

<p>So that all works very well. My problem is once my general dashboard page loads, none of the lables update unless I hit refresh.</p>

<p>Here is the page_load for the general dashboard</p>

<pre><code>    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["SiteID"] != null)
        {
            SiteID = int.Parse(Session["SiteID"].ToString());
             PopulateAccountData();
             PopulateAccountInformation2();
             PopulateSiteNodes();

        }
        else
             LabelSiteName.Text = "No Site Selected";
    }

void PopulateAccountData()
    {

        DataAccess da = new DataAccess();
        da.AddParameter("SiteID", SiteID, DataAccess.SQLDataType.SQLInteger, 4);
        SiteHeader = da.runSPDataSet("Portal_GetDashboardInfo");

        LabelGeneralManagerFirstName.Text = SiteHeader.Tables[0].Rows[0]["FirstName"].ToString();
        LabelGeneralManagerLastName.Text = SiteHeader.Tables[0].Rows[0]["LastName"].ToString();
        LabelSite.Text = SiteHeader.Tables[0].Rows[0]["SiteName"].ToString();
    }
</code></pre>

<p>I'm not sure if I'm doing it right. Once the user logs in they are directed to the dashboard page and it will always show No Site Selected unless they refresh.</p>

<p>Any ideas on how to properly do this?</p>

<p>HTML Code for site Picker</p>

<pre><code>&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;asp:Button ID="ClientButton" runat="server" OnClick="ClientButton_Click" Text="Select Client" /&gt;&lt;/td&gt;
&lt;td style="vertical-align:top"&gt;&lt;asp:DropDownList ID="DropDownListClient" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListClient_SelectedIndexChanged" Visible="False" Height="36px"&gt;
    &lt;/asp:DropDownList&gt;&lt;/td&gt;

&lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;    
&lt;td&gt;&lt;asp:Button ID="SiteButton" runat="server" OnClick="SiteButton_Click" Text="Select Site" /&gt;&lt;/td&gt;
&lt;td style="vertical-align:top"&gt;&lt;asp:DropDownList ID="DropDownListSite" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListSite_SelectedIndexChanged" Visible="False" Height="36px"&gt;
    &lt;/asp:DropDownList&gt;&lt;/td&gt;


&lt;/tr&gt;

&lt;/table&gt;
</code></pre>
