Gridview可以在多用户应用程序中显示特定登录用户的数据

编程入门 行业动态 更新时间:2024-10-14 14:18:15
本文介绍了Gridview可以在多用户应用程序中显示特定登录用户的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对于多用户应用程序,例如假设许多用户存储的基于Web的项目列表 Gridview是否可以显示与特定登录用户有关的数据. 同样,当用户登录时,他将被重定向到具有Gridview控件的页面,该控件 从数据库中获取并显示与该特定登录用户有关的数据,并仅向他显示他的数据. 就像为这些表假设的一样- 登录表>>> 用户名|密码 ------ | -------- ------ | -------- ------ | -------- ------ | -------- ------ | -------- (其中userid是主键) 和 产品表>>< br/> 产品编号|产品名称类别|用户名 ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- ---------- | ------------- | -------------- | ------- (其中ProductId是主键,而Userid是外键) 在这里,我希望Gridview从Product表中按照登录的User(Userid)获取数据,并显示他或她的 仅限产品. 我需要什么概念来实现这一目标.我是否还需要参加会议? 如果有人可以提供帮助并在其上写文章,这将非常有帮助.

For a multi-user application , like suppose a web based item list stored by many users Is it possible for Gridview to display data related to particular Logged in user. Also when the user Logs in , he gets redirected to a page with Gridview control that fetches and shows data related to that particular logged in user from database and displays him his data only. Like suppose for these tables - Login Table>>> Userid | Password ------ | -------- ------ | -------- ------ | -------- ------ | -------- ------ | -------- (where userid is Primary key) and Product Table>>> ProductID | Productname | category | Userid ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- ----------|-------------|----------|------- (where ProductId is primary key and Userid is Foreign key) Here i want Gridview to fetch data as per logged in User(Userid) from the Product table and display his or her Products only. What concept i''ll be needing for this to make happen. Will i need Sessions also in this ? If someone can Help and make an article on it please it will be very helpful.

推荐答案

步骤: 1.在会话中存储用户ID. 2.在从db进行gridview数据获取时,使用查询作为从user_id =(session中的user_id)表中选择列. 3.将数据绑定到Gridview并完成. Steps: 1. Store userid in a session. 2. while datafetch from db for gridview,use query as "select Columns from table whjere user_id=(user_id in session). 3. Bind data to Gridview and done.

您只需要查询产品表并将登录的用户ID 传递给查询参数. 以下查询是您所需要的. You just need to query to Product Table and pass logged in User Id as a parameter to the query. The following query is something what you need. SELECT ProductID, Productname, category FROM ProductTable WHERE UserId = @LoggedInUserId

您需要使用ADO.NET对象并使用SQLCommand类,然后使用此查询对其进行初始化. 您指定参数,然后将登录User Id"作为参数传递. 请参考-为命令添加参数 [ ^ ] 对于User Id,您可以使用 Session 进行存储和检索.

You need to use ADO.NET objects and use SQLCommand Class and initialize that using this query. You specify parameter and pass the Logged in User Id as a parameter. Refer - Adding Parameters to Commands[^] For User Id, you can use Session to store and retrieve.

更多推荐

Gridview可以在多用户应用程序中显示特定登录用户的数据

本文发布于:2023-10-24 21:10:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1525016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多用户   应用程序   数据   用户   Gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!