473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1050
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.visible = true
else
editbutton.visible = 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 "OnItemDataBound" event and hiding
the buttons for each row?
"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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.visible = true
else
editbutton.visible = 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 "OnItemDataBound" event and hiding
the buttons for each row?
"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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.visible = true
else
editbutton.visible = 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**********************************@microsoft.co m>,
Pa**@discussions.microsoft.com says...
Not sure, could try the role check in the page load event first.

The "edit" link is an ASP.NET EditCommandColumn 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
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....
8
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...
12
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...
0
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"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.