title: populating GridView with sql data
body: <p>I need to select from my users table the username of the user that has the roleID that I will have to get from the dropdownlist. The data are not appearing in the GridView. Can't see what's wrong, help me please.
  Already tried 2 ways</p>
  
  <pre><code>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
     {
         SqlConnection con = new SqlConnection(cs);
         con.Open();
         SqlCommand cmd = new SqlCommand("select username from tblUser where roleID like '" + DropDownList1.SelectedValue + "'", con);
  
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         da.Fill(dt);
         GridView2.DataSource = dt;
         GridView2.DataBind();
         con.Close();
     }
  
  protected void Button2_Click(object sender, EventArgs e)
  {
      SqlConnection con = new SqlConnection(cs);
      con.Open();
      SqlCommand cmd = new SqlCommand("select username from tblUser where roleID like '" + DropDownList1.SelectedValue + "'", con);
  
      SqlDataReader reader = cmd.ExecuteReader();
  
      GridView2.DataSource = reader;
      GridView2.DataBind();
      con.Close();
  }
  </code></pre>