|
| Available to administrator but not normal users |
 |
Tue, 1 Apr 2008 19:20:18 +0000 |
Hows it going, i have a gridview (GridView1) that shows name and number of a
horse, when one is selected a formview (FormView1) comes up with the rest of the
details on the horse with add, edit delete buttons available at the bottom. How
can i make it that only the administrator can view FormView1. I have been using
the built in login controls but just can find a way to single out just this to
be the only thing that the normal user can not see.
Any suggestions?
Thanks
|
| Post Reply
|
| Re: Available to administrator but not normal users |
 |
Tue, 1 Apr 2008 19:43:11 +0000 |
You can actually disable the links in RowDataBound event of the gridview. You
can check the role of the currently logged on user and disable the link column
if s/he is not an administrator. Does formview display in the same page or a
different page.
|
| Post Reply
|
| Re: Available to administrator but not normal users |
 |
Tue, 1 Apr 2008 20:39:26 +0000 |
Hows it going Pitbull, thanks for the reply, sorry I dont think i was very clear
in the description, FormView1 comes up beside DetailsView1 when one is selected.
Im kinda new to ASP.net and have been thinking for ages for simple ways of doing
this but nothing is clicking yet. All i really got so far is to have something
like an if statement that if the user is administrator = false then FormView1
visible = false. But im thinking there must be some kind of simple command or
even drop down list in the properties of the FormView that can control this?
Cheers
Take it handy
|
| Post Reply
|
| Re: Available to administrator but not normal users |
 |
Tue, 1 Apr 2008 20:46:43 +0000 |
Everything is going great! How about u?
Nope...there is nothing as a property that you can use to do this kind of stuff.
You have to find a way thru code. Also, are you using (GridView and FormView) or
(DetailsView and FormView). What I meant in my last post was that if you are
using GridView, there is an event called RowDataBound in which you can get
access to cells and rows of the gridview. Hiding FormView is also an option.
There is nothing wrong in doing that either. You can also hide or show the
column in gridview according the user's role.
|
| Post Reply
|
| Re: Available to administrator but not normal users |
 |
Wed, 2 Apr 2008 00:26:04 +0000 |
All is grand here boss thanks for asking,
I see i was contradicting myself, I am using GridView and FormView. I dont
really think im advanced enough to do the RowDataBound you suggested but i did
try the if ststement. I tried it twice with these 2
FormView1_load and FormView1_ItemCommand both times with the code
if (Roles.IsUserInRole("Admin") = True) Then
FormView1.Visible = True
Else
FormView1.Visible = False
End If
End Sub
Both times a normal user was able to view FormView1 when an item in GridView1
was selected. Not sure if Im just confusing things here but any further help
would be really appreciated.
Thanks
|
| Post Reply
|
|
|
|
|
|
|
|
|
|