如何根据谁登录在Gridview上显示用户信息? [英] How to Display User info on Gridview based on who is login?
问题描述
我有一张桌子个人信息,所有客户都必须填写此内容,
我有一个Gridview,我想根据谁是用户显示用户个人资料登录。
用户成功登录后,使用 ADO.NET $通过SQL查询从数据库中获取他/她的信息c $ c>对象。
因为你需要在 GridView
上显示,然后使用 SqlAdapter
Class和填写
你的 GridView
。
< blockquote>看一下ASP.Net中的角色和成员资格 -
https://www.asp.net/web-forms/tutorials/security/roles/creating-and-managing-roles-cs [ ^ ]
了解ASP.NET角色和成员资格 - 初学者教程 [ ^ ]
http://msdn.microsoft.com/en-us/library/yh26yfzy%28v=vs。 100%29.ASPX [ ^ ]
使查询成为一种不必编写另一个查询的方式。例如,
SELECT * FROM 用户 WHERE 电子邮件= @ email 和密码= @ password
这将全部返回符合条件的记录。
现在,在Button_Click或任何控件事件上,
SqlCommand cmd = new SqlCommand( 您的查询,connectionObject);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
userGridView.DataSource = dt;
userGridView.DataBind();
您可以根据自己的要求操作此代码。这只是你如何处理问题的基本想法。
希望你能清楚这一点。
-KR
I have a table Personal info, all customer must fill this up,
I have a Gridview and I want to display the user profile based on who is user that log in.
After User successfully logins, fetch his/her information from Database by a SQL Query usingADO.NET
objects.
As you need to show onGridView
, then useSqlAdapter
Class andFill
yourGridView
.
Have a look at roles and membership in ASP.Net -
https://www.asp.net/web-forms/tutorials/security/roles/creating-and-managing-roles-cs[^]
Understanding ASP.NET Roles and Membership - A Beginner's Tutorial[^]
http://msdn.microsoft.com/en-us/library/yh26yfzy%28v=vs.100%29.ASPX[^]
Make the query such a way that you don't have to write another one. For example,
SELECT * FROM User WHERE Email = @email and Password = @password
This would return all the records that has matched criteria.
Now, on Button_Click or any event of the control,
SqlCommand cmd= new SqlCommand("your query", connectionObject); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); userGridView.DataSource = dt; userGridView.DataBind();
You can manipulate this code as per your requirements. This is just the basic idea how you can deal with your problem.
Hope this much is clear to you.
-KR
这篇关于如何根据谁登录在Gridview上显示用户信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!