By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

only allow editing Datagrid if a user is authorized

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.