only allow editing Datagrid if a user is authorized

S

Steve

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...
 
G

Guest

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.
 
S

Steve

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?
 
D

Diane Wilson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top