title: Get data field of the selected row in Gridview using button field in ASP.net
body: <p>There are two pages named: People.aspx and Profile.aspx.</p>
  
  <p>People.aspx -> contains the name of all users</p>
  
  <p>Profile.aspx -> contains the information of each user</p>
  
  <p>In the first page, People.aspx, I have a Gridview named <strong>peopleGridview</strong> and when I am loading the page name <strong>People.aspx</strong>, in <code>Page_Load</code> event I call a method that executes a sql query on database and gets all the fields that I need to put in my Gridview.</p>
  
  <p>The SQL query is like this:</p>
  
  <pre><code>public DataSet PeopleList()
      {
          GetConnection();
          SqlCommand command = new SqlCommand("SELECT Members.ID, Members.Full_Name, Members.Position, Members.Status, Profile.Address" +
                                              " FROM Members" +
                                              " INNER JOIN Profile" +
                                              " ON Members.ID = Profile.ID"+
                                              " ORDER BY Members.Priority, Members.Membership_Date, Members.Full_Name", con);
          SqlDataAdapter da = new SqlDataAdapter(command);//da: DataAdapter 
          DataSet ds = new DataSet();//ds: Dataset
          da.Fill(ds);
          con.Close();
          return ds;
      }
  </code></pre>
  
  <p>In Gridview I only need to show the fields <strong>Full_Name</strong>, <strong>Position</strong>, <strong>Status</strong> and <strong>Address</strong> and I do not want to show the value of the field <strong>ID</strong> (because it is not necessary for ordinary users to know the ID of other users). </p>
  
  <p>I have a button field in my Gridview for each row and I want whenever that I clicked on the button field of the selected row, read the field <strong>ID</strong> of the selected row (that is not currently shown in Gridview) and put it in the <code>Response.Redirect("Profile.aspx?UserID=" + userid.Text.ToString());</code> as an argument for the <strong>userid</strong> in order to send it to <strong>Profile.aspx</strong> that is another page that contains the information about that user.</p>
  
  <p>How do I do such a work? In addition, how can I get the value of UserID on the side of Profile.aspx</p>
  
  <p>I did the work using Link field in Gridview, however I am not able to do such a work using button field in GridView. </p>