473,804 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

only allow editing Datagrid if a user is authorized

I haven't used authentication/authorization in awhile. I'm having a hard
time deciding how to display the edit column in a datagrid ONLY if a user
with proper credentials is logged in. In other words, if 'joe public' goes
to the site, I don't want him to see the edit options, however if an admin
is logged in, I want them to see the edit icon.

How do you do this?
Thanks for any help, I'm sure I just need my memory jarred...
Nov 19 '05 #1
4 1063
Could do something like
'get user role-could be a number depending on how you set it up.

if userrole = 1 ' userrole 1 = admin
editbutton.visi ble = true
else
editbutton.visi ble = false
end if.
If you are keeping track of the users and roles in a database table you
would at first have to get the information and then test the role.
--
Paul G
Software engineer.
"Steve" wrote:
I haven't used authentication/authorization in awhile. I'm having a hard
time deciding how to display the edit column in a datagrid ONLY if a user
with proper credentials is logged in. In other words, if 'joe public' goes
to the site, I don't want him to see the edit options, however if an admin
is logged in, I want them to see the edit icon.

How do you do this?
Thanks for any help, I'm sure I just need my memory jarred...

Nov 19 '05 #2
Hi Paul, thanks for the response.
Yes, I will be keeping track of the roles in a DB. From your example, it
seems that I would be evaluating for each "OnItemDataBoun d" event and hiding
the buttons for each row?
"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com...
Could do something like
'get user role-could be a number depending on how you set it up.

if userrole = 1 ' userrole 1 = admin
editbutton.visi ble = true
else
editbutton.visi ble = false
end if.
If you are keeping track of the users and roles in a database table you
would at first have to get the information and then test the role.
--
Paul G
Software engineer.
"Steve" wrote:
I haven't used authentication/authorization in awhile. I'm having a hard time deciding how to display the edit column in a datagrid ONLY if a user with proper credentials is logged in. In other words, if 'joe public' goes to the site, I don't want him to see the edit options, however if an admin is logged in, I want them to see the edit icon.

How do you do this?
Thanks for any help, I'm sure I just need my memory jarred...

Nov 19 '05 #3
Not sure, could try the role check in the page load event first.
--
Paul G
Software engineer.
"Steve" wrote:
Hi Paul, thanks for the response.
Yes, I will be keeping track of the roles in a DB. From your example, it
seems that I would be evaluating for each "OnItemDataBoun d" event and hiding
the buttons for each row?
"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com...
Could do something like
'get user role-could be a number depending on how you set it up.

if userrole = 1 ' userrole 1 = admin
editbutton.visi ble = true
else
editbutton.visi ble = false
end if.
If you are keeping track of the users and roles in a database table you
would at first have to get the information and then test the role.
--
Paul G
Software engineer.
"Steve" wrote:
I haven't used authentication/authorization in awhile. I'm having a hard time deciding how to display the edit column in a datagrid ONLY if a user with proper credentials is logged in. In other words, if 'joe public' goes to the site, I don't want him to see the edit options, however if an admin is logged in, I want them to see the edit icon.

How do you do this?
Thanks for any help, I'm sure I just need my memory jarred...


Nov 19 '05 #4
In article <16************ *************** *******@microso ft.com>,
Pa**@discussion s.microsoft.com says...
Not sure, could try the role check in the page load event first.

The "edit" link is an ASP.NET EditCommandColu mn control in
the Columns collection of the data grid. It should be possible
to delete this column from the columns collection, although I haven't
tried writing the code to detect it.

Diane
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1663
by: joe | last post by:
Some time ago I set up an ASP application that used a login page which checked a username and password against a database to determine a users authorization to access certain pages on the site. This was done by setting a session variable within the application if the user was authorized and using code one each page for which protection was required to check for the status of the session variable. Now I am aware of the various techniques...
8
2411
by: pmud | last post by:
Hi, I have 2 questions: 1. I have an editable data grid with 21 columns. I need to edit only 2 cloumns in this data grid. But when the grid is displayed in Edit mode, all the columns show long text boxes whichmakes the user to SCROLL a lot. I need only these 2 cloumns to be displayed in Edit mode. Is that possible & how? 2. Also, even when the data grid is not displayed in the edit mode, it
12
1818
by: dino d. | last post by:
hi everyone- my subject pretty much says it all- is there a secure way to do this? the non-secure ways are, as i understand it, to populate a listbox with indices as names, or maybe use a hidden control. is the only secure way with sessions? i was also thinking about perhaps creating a meta table that says who is editing which record right now. any advice? thanks, dino
0
1314
by: hanusoft | last post by:
This is an example of editing in DataGrid and Default Paging http://www.hanusoftware.com Html Design Code : - <asp:DataGrid id="DataGrid1" DataKeyField="id" runat="server" Height="224px" AutoGenerateColumns="False" PageSize="5" AllowPaging="True"> <Columns> <asp:BoundColumn Visible="False" DataField="id" HeaderText="Category Id"></asp:BoundColumn>
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.