How to databind a dropdownlist at page load
<p>Assuming i have two dropdownlists namely: dropdownlistA and dropdownlistB. at page load, i bind values to dropdownlistA. however, depending on the value selected or displayed in dropdownlistA, i want to bind data to dropdownlistB.</p>

<p>Currently, i can bind data to dropdownlistA alright and i already have the required dataset and datatable bind data to dropdownlist. However, dropdownlistB does not bind at page load since the criteria for filling the dataset to bind dropdownlistB (which is the value of dropdownlistA) is not selected. how can i make this wwork.</p>

<p>I am currently considered if this might work. If i were to call the databind for dropdownlistA in a different declared method besides its binding in page load, and select the value from bind in the declared method, would any value be selected?</p>

<p>For example:
  In during page load, i call the a method that returns dataset values which i bind to dropdownlistA(caseIDDropDownList). then i call another method (CreateexhibitDataSet()) which contains the dataset values for binding dropdownlistB(exhibitDropDownList). however, i need to define a criteria in the CreateExhibitDataset() method which i will use to generate the dataset values to bind dropdownlistB. if i were to call for the data bind of dropdownlistA(caseIDDropdownList) again in the CreateExhibitDataset() method and pick the value in the dropdown list, would i get any values?</p>

<p>How can i work around this to bind both dropdownlists on page load?</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        //mgrID = "M510";
        //mgrID = Request.QueryString["mgrID"];
        mgrID = (string)(Session["userID"]);

        if (mgrID != null)
        {
            if (!IsPostBack)
            {
                CreateCasesDataset();
                DataView caseDataView = new DataView(caseDataSet.Tables[0]);
                caseIDDropDownList.DataSource = caseDataView;
                caseIDDropDownList.DataTextField = "CaseID";
                caseIDDropDownList.DataBind();

                CreateExhibitDataset();

                DataView exhibDataView = new DataView(exhibitDataSet.Tables[0]);
                exhibitsDropDownList.DataSource = exhibDataView;
                exhibitsDropDownList.DataTextField = "ExhibitID";
                exhibitsDropDownList.DataBind();
            }
        }
        else
        {
            string message = "The System couldnt identify you with any ID. Please Log in to access system functions";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("&lt;script type = 'text/javascript'&gt;");
            sb.Append("window.onload=function(){");
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("')};");
            sb.Append("&lt;/script&gt;");
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
        }

    }
</code></pre>

<p>And this is the additional code of the CreateExhibitMethod</p>

<pre><code>private void CreateExhibitDataset()
    {
        caseIDDropDownList.DataBind();
        string selectedCaseID = caseIDDropDownList.SelectedValue.ToString();

        SqlConnection exhibitConnection = new SqlConnection(strConn);
        exhibitSqlDataAdapter.SelectCommand = new SqlCommand("SELECT ExhibitID FROM Exhibits WHERE CaseID = '"+selectedCaseID+"'", exhibitConnection);
        exhibitSqlDataAdapter.Fill(exhibitDataSet);
    }
</code></pre>
