title: How to show a specific item in dropdownlist based on specific value of a cell of a table-row in asp.net gridview control?
body: <p>i am new to asp.net. I am building an admin page and i want to display employee's data in GridView by fetching it from database table. Table has 3 columns (id, name, isManager). There are three possible values for "isManager" column. These values are "yes", "no" and "null". The admin has right to decide for an employee to make him a manager by selecting "yes" or "no" from DropDownList.</p>
  
  <p>This admin page has a GridView control that contains two BoundFileds (i.e. id &amp; name) and one template field (i.e. DropDownList). I am having difficulty in displaying "isManager" column values in DropDownList. I want DropDownList to display selected value/text as "yes" if database table-row has "yes" in "isManager" column, "no" if there is "no" in table-row and display an item "Select Choice" if table-row contains a null value.</p>
  
  <p>My code:  </p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
   {
     string query = "select * from tblUsersTable";
     DataSet ds = DataBaseConnectivity.GetData(query);
     GridView1.DataSource = ds;
     GridView1.DataBind();
    }
   }
  
   // RowDataBound() method
  
  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
     if (e.Row.RowType == DataControlRowType.DataRow)
       {
         //Find the DropDownList in the Row
        DropDownList ddlManager = (e.Row.FindControl("ddlManager") as DropDownList);
        DataSet ds = DataBaseConnectivity.GetData
                                   ("select distinct [isManager] from tblUsersTable");
        ddlManager.DataSource = ds; 
        ddlManager.DataTextField = "isManager";
        ddlManager.DataValueField = "isManager";
        ddlManager.DataBind();
        ddlManager.Items.Insert(0, new ListItem("Please select","-1"));
  
        /* After these lines of code i am not finding the right way to implement my logic
          */
  </code></pre>
  
  <p>Help me to figure it out.</p>