asp.net中的网格视图仅使用c#编辑选定的行 [英] Grid View in asp.net editing only selected rows using c#

查看:82
本文介绍了asp.net中的网格视图仅使用c#编辑选定的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个网格视图,并启用了编辑,插入,删除功能。如何在数据库中的选定列(即)上提供这些选项,其中信息由多个用户存储,当他/她登录时,应该只能编辑其记录而不能编辑网格视图中的其他记录?

I have created a grid view and enabled editing, inserting , deleting. How to make these options available on to selected columns (i.e) in a database where information is stored by more than a single user, When he /she logs in , should be able to edit only their records and not other records in the grid view?

推荐答案

您必须保存用户ID,以便当前用户ID与该行的ID(比如CreatedBy)匹配,然后启用按钮

没有必要在用户登录时每次在会话中保存UserId时进行比较,然后将此ID发送到数据库,这样....

有很多方法....

首先尝试自己做,如果你卡在某处,那么我们在这里寻求帮助

希望这有助于

- 快乐编码
You must have save Id of Users so if Current User Id Matches the Id(say CreatedBy) of that row then Enable Button
It's not necessary to Compare this every time you can save UserId in session while user Log in and then send this id to database so....
there are many ways....
First try to do it yourself and if You stuck somewhere then we are here for Help
Hope This Helps
--Happy Coding


为此,你必须从用户表中对该表的外键有一些关系



然后在绑定 GridView 时,您可以检查当前用户获取了外键列,如果匹配,则选项将可用,否则不可用。



因此,引用的行由当前用户仅适用于编辑插入删除
For that you must have some Relationship in terms of Foreign Key to that table from the User table.

Then while binding the GridView, you can check the Current User against that fetched Foreign Key column and if it matches, then the options will be available, else not.

So, the rows Referenced by the Current User will only be available for Editing, Inserting and Deleting.


这篇关于asp.net中的网格视图仅使用c#编辑选定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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