Click here to Skip to main content
15,913,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a page of user details in which name, father name, mother name, class, roll no. etc.
I want to show several fields in gridview like in which i want to show user name, class, roll no..
My first Page is login page. Now I Want, as i login with a user name. That user name will compare by gridview and show that detais of a login user only.
as i login redirect to another page of gridview with that details on page load.
Posted
Comments
DamithSL 8-May-14 3:17am    
where you store user data?
Ankit 71 8-May-14 3:33am    
in sql
oliver grace 8-May-14 3:18am    
you can campare fields with the help of dataset or datatable.Then you can bind datatable in gridview.
Ankit 71 8-May-14 3:36am    
my code is: SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sst"].ToString());
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from mastertable ", con);
DataSet ds = new DataSet();

da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
con.Close();
now i show the record on that field that i have selected,, but all the users that lies in that table not the login user.

1 solution

you need to use where condition in your sql statement, for example;
C#
string userName =lblUserName.Text;
SqlDataAdapter da = new SqlDataAdapter("select * from mastertable where username ='"+ userName +"'", con);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900