title: Dropdown list default value on button click
body: <p>I'm working on an asp project. I have a situation where I need to search files and display in gridview. The gridview have three drop down list, my problem now is how can I show the default value of my dropdown based on the result set returned when I click the search button, since I already set the default value of the drop down ("Please Select") on data row bound. Because at first load my drop down should show "please select" value. Thanks a lot for the help. below is my code. </p>
  
  <pre><code> protected void btnSearch_Click(object sender, EventArgs e)
  {
      int uFlag = 0;
      string uploadFlag = this.ddlUploadDate.SelectedValue;
      string fileName = this.txtSearchText.Text;
      string uploadDt = this.txtDate.Text;
      string status = this.ddlStatus.SelectedValue.ToString();
  
      List&lt;EventFile&gt; fileSearch = new List&lt;EventFile&gt;();
      fileSearch = CoMailAssociationDAL.SearchFile(uFlag, fileName, uploadDt, status);
  
      gvwAssociation.DataSource = fileSearch;
      gvwAssociation.DataBind();
  }
  
   protected void gvwAssociation_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      ListItem Item = new ListItem();
      Item.Text = "Please Select";
      Item.Value = "0";
      Item.Selected = true;
  
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          DropDownList ddlpool = (DropDownList)e.Row.FindControl("ddlpool");
          DropDownList ddlyear = (DropDownList)e.Row.FindControl("ddlyear");
          DropDownList ddlevent = (DropDownList)e.Row.FindControl("ddlevent");
  
          ddlpool.DataSource = CoMailAssociationDAL.GetCoBindEvents();
          ddlpool.DataBind();
          ddlpool.Items.Insert(0, Item);
  
          ddlevent.DataSource = CoMailAssociationDAL.GetCoBindEvents();
          ddlevent.DataBind();
          ddlevent.Items.Insert(0, Item);
  
          for (int intCount = 2013; intCount &lt;= 2020; intCount++)
          {
              ddlyear.Items.Add(intCount.ToString());   
              ddlyear.SelectedIndex = 1;             
          }
      }
  }
  </code></pre>