CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.security Tags:
Item Type: NewsGroup Date Entered: 11/27/2006 9:34:13 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 28 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
mso789
Asp.Net User
gridview security11/27/2006 9:34:13 PM

0/0

I am building an application that need to be flexible enough to hide certain pieces of information withing a page based on who the user is.  

 

More specifically, I have a gridview/formview which needs to allow certain users to edit/insert/delete information while at the same time would limit other users to view information.

Is this possible and how will I go about doing this ?

Thanks in advance.

ulysses098
Asp.Net User
Re: gridview security11/28/2006 1:37:08 AM

0/0

yes. you can access the controls inside a gridview and formview, then their are events in the gridview called rowdatabound which you can use to show or hide certain controls inside that row.
mso789
Asp.Net User
Re: gridview security12/5/2006 10:03:18 PM

0/0

What about the FormView controls.   How do I allow administrators to see the edit/insert/delete functions and hide those controls from any other user ?

Also, going back to your response, what exactly am I to type under the rowdatabound gridView control ?  Can you provide me with a sample ?

Thanks.
 

benvan
Asp.Net User
Re: gridview security12/8/2006 2:22:22 AM

0/0

This is a very good example of how NOT to ask a question.

 

Do you have any knowledge of C# or VB?

 on rowcreated, Use e.Row.Cells( index of required cell, in this case probably 0 ).Visible = False

 

likewise, change the index for any other columns which you want to hide. I would suggest writing a hidecolumns function.

ulysses098
Asp.Net User
Re: gridview security1/5/2007 3:45:56 AM

0/0

well let us assume you have a usertype session that will determine if we will view the edit/insert/delete button.

    protected void example_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            if(Session["usertype"] == "admin"){
                    Button btnsample= (Button)e.Row.FindControl("insertbutton");

                     btnsample.visible = true;
             }

            else

            {

                    Button btnsample= (Button)e.Row.FindControl("insertbutton");                    

                    btnsample.visible = false;

            }
        }
    }

ulysses098
Asp.Net User
Re: gridview security1/5/2007 3:51:47 AM

0/0

you can also use the load event of a formview, and put the condition of hiding and showing the edit/insert/delete button.
mlawton40
Asp.Net User
Re: gridview security3/5/2007 11:06:24 AM

0/0

Hi, Im just trying this and have the following code, which I have used from the  

protected void Delete_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Roles.IsUserInRole(User.Identity.Name, "Administrator"))
            {
                ImageButton btnDel = e.Row.Cells[6].Controls[0] as ImageButton;
                btnDel.visible = true;
            }
            else
            {
                ImageButton btnDel = e.Row.Cells[6].Controls[0] as ImageButton;
                btnDel.Visible = false;
            }
        }
    } 
 above example.

 

The problem is the following message appears:

'System.Web.UI.WebControls.ImageButton' does not contain a definition for 'visible'

Any idea? Cheers, Mark

macal_vm
Asp.Net User
Re: gridview security3/5/2007 11:36:54 AM

0/0

also, u can aways create a admin.aspx page and set the view to insert/edit or whatever u want. the same way, u can set the view for normal users to read only.

this way u need only to protect the page.

mlawton40
Asp.Net User
Re: gridview security3/5/2007 11:42:15 AM

0/0

but any ideas about the above problem?

 Cheers, Mark

9 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Databases Authors: Thiru Thangarathinam, Pages: 504, Published: 2007
Beginning ASP.NET 2.0 Databases: Beta Preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 427, Published: 2005
Professional ASP.NET 2.0 Security, Membership, and Role Management Authors: Stefan Schackow, Pages: 611, Published: 2006
Visual Web Developer 2005 Express Edition For Dummies Authors: Alan Simpson, Pages: 358, Published: 2005
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Professional VB 2005 Authors: Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Rama Ramachandran, Kent Sharkey, Bill Sheldon, Pages: 1066, Published: 2006
Visual Basic 2005: A Developer's Notebook Authors: Matthew MacDonald, MacDonald Matthew, Pages: 243, Published: 2005
Microsoft Visual C# 2005 Unleashed Authors: Kevin Hoffman, Pages: 692, Published: 2006
Beginning ASP.NET 2.0 Databases: From Novice to Professional Authors: Damien Foggon, Pages: 625, Published: 2006

Web:
Controlling column width in a GridView - Security Briefs ... I've been building some internal pages for our sales team here at Pluralsight , and many of those pages make use of the ASP.NET GridView control to display ...
gridview security - ASP.NET Forums More specifically, I have a gridview/formview which needs to allow certain users to edit/insert/delete information while at the same time would limit other ...
Hide a column in asp:GridView column in asp:GridView invisible, I cannot get the value from that column. Ah... You've discovered the additional security feature that a ...
gridview in asp.net Sep 29, 2008 ... Tags: feedback, windows, security, software, career, networking, ... many link buttons in gridview..when i click on particular linkbutton i ...
ObjectDataSourceFilteringEventArgs Class (System.Web.UI.WebControls) The code example consists of a TextBox control, a GridView control, ... contains a text box that accepts user input, which is a potential security threat. ...
GridView does not show when bound to DataTable : vb.net As the title suggests, I have a gridview that is being databound to a datable. ... Operating Systems Security; Software Firewalls; Vulnerabilities ...
GridView -enable editing - Application Development Forum GridView grid = sender as System.Web.UI.WebControls.GridView; System.Web. Security.MembershipUser userToUpdate = System.Web.Security. ...
No Slide Title GridView uses state-of-the-art. modeling technology to simulate. security constrained unit commitment. and economic dispatch in large-scale ...
DotNetSlackers: Displaying Extended Details in a GridView Using an ... Jul 4, 2007 ... NET 2.0 web applications, the GridView control is commonly used to ... NET Professional 6.6.2.2 with new Converters more; Security and Ajax. ...
GridView -enable editing GridView grid = sender as System.Web.UI.WebControls.GridView; System.Web. Security.MembershipUser userToUpdate = System.Web.Security.Membership. ...




Search This Site:










help ! table background image doesnt work !!

frames control

i am lost

nt authority/networkservice not showing as user in sql

menu control source (vertical)

for those of you who used the seaburydesign videos

changing themes at run time

nested logins

datetime format in gridview

converting minutes to hours

error rendering control - there was an error parsing the theme: code blocks are not allowed in this file

how to traverse a comma seperated string?

datetime formatexception when casting string to short

ssl install

validation on property set?

learning environment

download for cms postnuke manipulated

is there a way to control alignment for admin modules ?

how do you determine which of a pages user controls caused a postback?

metabuilders.com

file manager out of sync

wierd behavior: buttons & labels change position

breakpoint does not stop in web app under iis 6

datatable to dataset

using vs2005, source control and different development levels

2.0.3 modules: add new with page admin

where to keep dll for code behind

3 tier architecture using latest enterprise library

university portal

tableprofileprovider & enum property type

 
All Times Are GMT