Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: How to hide datagrid column based on user role

Reply
Thread Tools

Re: How to hide datagrid column based on user role

 
 
Raterus
Guest
Posts: n/a
 
      02-19-2004
I've always just set the column I want(with an id set so you can access it)
"visible" to "false"

<asp:boundcolumn id="myBoundCol2Hide" runat="server">
...
myBoundCol2Hide.visible = false

this doesn't stop any binding to the column though, it just doesn't display
it when it is rendered.

"Reza Nabi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a datagrid control. Based on the user role, i need to hide one of

the column (the first column with a magnifying glass icon).
> Lets say, if urser's roleID is 1, they can have have the link button to

edit the clientele number.
> What is the best way to accomplish this?
> Any help/pointer would be grealy appreciated.
> Thanks,
>
> Reza Nabi
>
> ---begin datagrid ----
>
>
> &lt;asp:datagrid runat="server" id="gridCurrentErrors"

autogeneratecolumns="false" &gt;
> &lt;headerstyle backcolor="#797979" font-bold="true" forecolor="white"

horizontalalign="center" /&gt;
> &lt;alternatingitemstyle backcolor="#eeeeee" /&gt;
> &lt;pagerstyle backcolor="#797979" font-bold="true" forecolor="white"

/&gt;
> &lt;Columns&gt;
> &lt;asp:buttoncolumn runat="server" headertext=""
> buttontype="linkbutton" commandname="EditClieteleCall"
> Text="&lt;img title='Edit Clientele call...' border='no'

src='images/mg.gif' /&gt;" &gt;
> &lt;/asp:buttoncolumn&gt;
> &lt;asp:boundcolumn runat="server" datafield="clientele_call"

headertext="Call Number" /&gt;
> &lt;asp:boundcolumn runat="server" datafield="starttime"

headertext="Start" /&gt;
> &lt;asp:boundcolumn runat="server" datafield="region_name"

headertext="Region" /&gt;
> &lt;asp:boundcolumn runat="server" datafield="site_name" headertext="Site"

/&gt;
>
> &lt;/Columns&gt;
> &lt;/aspataGrid&gt;
>
> ---end datagrid ----
>
> ---begin code behind to bind the datagrid---
> // get the role_id who currently loged on
> int roleID = Convert.ToInt32(RmsLiteSecurity.GetRoleID());
> int userID = Convert.ToInt32(RmsLiteSecurity.GetUserID());
> CurrentError ce = new CurrentError();
> DataSet ds = ce.GetCurrentErrors(userID);
> gridCurrentErrors.DataSource = ds.Tables[0].DefaultView;
> gridCurrentErrors.DataBind();
>
>
> ---end code behind to bind the datagrid ----



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmV6YSBOYWJp?=
Guest
Posts: n/a
 
      02-20-2004
Hello Raterus
Thanks so much for your prompt help. As per Suresh, following code did the trick
if (roleID == 1
gridCurrentErrors.Columns[0].Visible = true
els
gridCurrentErrors.Columns[0].Visible = false

Out of curiousity, i was trying your solutions as well. But when i was adding 'ID' attribute to BoundColumn i got the following error from visual studio.NET 2003
ERROR: Could not find any attribute 'ID' of element 'BoundColumn

Do i need to upgrade my visual studio
Thanks

Rez


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AzMan Role Based Security vs. ASP.NET Role Based Security Kursat ASP .Net Security 1 05-07-2007 01:33 PM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
RE: How to hide datagrid column based on user role =?Utf-8?B?U3VyZXNo?= ASP .Net 1 02-20-2004 02:06 PM
Role-Based Security: ACLs and Role Hierarchies Liet Kynes ASP .Net 0 11-26-2003 08:08 AM
Role-based security: Access the role of current user Jesper Stocholm ASP .Net 2 08-23-2003 06:59 PM



Advertisments