如何根据谁登录在Gridview上显示用户信息? [英] How to Display User info on Gridview based on who is login?

查看:239
本文介绍了如何根据谁登录在Gridview上显示用户信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子个人信息,所有客户都必须填写此内容,



我有一个Gridview,我想根据谁是用户显示用户个人资料登录。

解决方案

用户成功登录后,使用 ADO.NET 对象。



因为你需要在 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 using ADO.NET objects.

As you need to show on GridView, then use SqlAdapter Class and Fill your GridView.


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆