Dropdownlist Selected value in postback
<p>I have 2 dropdownlists(ddl1,ddl2) and a gridview with 2 dropdown lists(gddl1,gddl2). On <code>SelectedIndexChanged</code> event of ddl1 am changing <code>SelectedIndex</code> of gddl1 in postback.</p>

<p>My problem is
ddl1.databind() occurs at a <strong>button's click event</strong>. So once selectedindex of ddl1 changes, the selected value losts and returns back to initial value.</p>

<p>I cant use <code>!IsPostback</code> because am binding ddl1 on button click.
How can I retain ddl1 and ddl2 selected index.?</p>

<pre><code>protected void btnProceed_Click(object sender, EventArgs e)
{
    if(ddlLocation.SelectedIndex &gt; -1) {
        empDS = ws_service.GetEmpList(ddlLocation.SelectedValue, ((ddlDept.SelectedValue == "All") ? "" : ddlDept.SelectedValue), ((ddlGrade.SelectedValue == "All") ? "" : ddlGrade.SelectedValue));
        appraiserDS = ws_service.GetAppList();
        grdDetails.DataSource = empDS.Tables[ 0 ].DefaultView;
        grdDetails.DataBind();

        ddlAppraiserAll.DataSource = appraiserDS.Tables[ 0 ].DefaultView;
        ddlAppraiserAll.DataTextField = "APPRAISER_NAME";
        ddlAppraiserAll.DataValueField = "APPRAISER_ID";
        ddlAppraiserAll.DataBind();
    }
}


protected void ddlAppraiserAll_SelectedIndexChanged(object sender, EventArgs e)
{
    foreach(GridViewRow gvRow in grdDetails.Rows) {
        Control ctrl = gvRow.FindControl("ddlAppraiserId");
        DropDownList ddl = ctrl as DropDownList;
        if(ddl != null)
            ddl.SelectedIndex = ddlAppraiserAll.SelectedIndex;
    }
}
</code></pre>
