There are two pages named: People.aspx and Profile.aspx.
People.aspx -> contains the name of all users
Profile.aspx -> contains the information of each user
In the first page, People.aspx, I have a Gridview named peopleGridview and when I am loading the page name People.aspx, in Page_Load 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.
The SQL query is like this:
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;
}
In Gridview I only need to show the fields Full_Name, Position, Status and Address and I do not want to show the value of the field ID (because it is not necessary for ordinary users to know the ID of other users).
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 ID of the selected row (that is not currently shown in Gridview) and put it in the Response.Redirect("Profile.aspx?UserID=" + userid.Text.ToString()); as an argument for the userid in order to send it to Profile.aspx that is another page that contains the information about that user.
How do I do such a work? In addition, how can I get the value of UserID on the side of Profile.aspx
I did the work using Link field in Gridview, however I am not able to do such a work using button field in GridView.