protected void loadCandidate()
{
con.Open();
MySqlCommand cmd = new MySqlCommand("select * from voter where studentID ='" + User.Identity.Name + "'", con);
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows == true)
{
GridView1.DataSource = dr;
GridView1.DataBind();
}
}
//This is my grid view
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
I'd like to let users see only their own data in the voter table.
For example, the user's id is 923WRC123, then the users can only see their own data which is the data belong to 923WRC123 without showing other users data in the grid view1.
I created a session to store the user ID when they login into their account.
There is no error message, but the grid view is empty, it should display the data belong to the users 923WRC123