RE: How to hide datagrid column based on user role

Discussion in 'ASP .Net' started by =?Utf-8?B?U3VyZXNo?=, Feb 19, 2004.

  1. if(roleID == 1
    yourDatagrid.Columns[IndexOfGlassIconColumn/0].Visible = true
    els
    yourDatagrid.Columns[IndexOfGlassIconColumn/0].Visible = false

    HTH
    Suresh

    ----- Reza Nabi wrote: ----

    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 Nab

    ---begin datagrid ---


    <asp:datagrid runat="server" id="gridCurrentErrors" autogeneratecolumns="false" &gt
    <headerstyle backcolor="#797979" font-bold="true" forecolor="white" horizontalalign="center" /&gt
    <alternatingitemstyle backcolor="#eeeeee" /&gt
    <pagerstyle backcolor="#797979" font-bold="true" forecolor="white" /&gt
    <Columns>
    <asp:buttoncolumn runat="server" headertext=""
    buttontype="linkbutton" commandname="EditClieteleCall"
    Text="<img title='Edit Clientele call...' border='no' src='images/mg.gif' />" &gt
    </asp:buttoncolumn>
    <asp:boundcolumn runat="server" datafield="clientele_call" headertext="Call Number" /&gt
    <asp:boundcolumn runat="server" datafield="starttime" headertext="Start" /&gt
    <asp:boundcolumn runat="server" datafield="region_name" headertext="Region" /&gt
    <asp:boundcolumn runat="server" datafield="site_name" headertext="Site" /&gt

    </Columns&gt
    </asp:DataGrid&gt

    ---end datagrid ---

    ---begin code behind to bind the datagrid--
    // get the role_id who currently loged o
    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 ----
     
    =?Utf-8?B?U3VyZXNo?=, Feb 19, 2004
    #1
    1. Advertising

  2. Dear Raterus & Suresh
    Thank you so much and i appreciated a lot your kind help. Good day

    Reza Nabi
     
    =?Utf-8?B?UmV6YSBOYWJp?=, Feb 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jesper Stocholm
    Replies:
    2
    Views:
    8,244
    John Saunders
    Aug 23, 2003
  2. Liet Kynes
    Replies:
    0
    Views:
    537
    Liet Kynes
    Nov 26, 2003
  3. Raterus
    Replies:
    1
    Views:
    1,652
    =?Utf-8?B?UmV6YSBOYWJp?=
    Feb 20, 2004
  4. vishnu
    Replies:
    1
    Views:
    1,251
    Patrick.O.Ige
    Mar 25, 2006
  5. Kursat
    Replies:
    1
    Views:
    340
    Dominick Baier
    May 7, 2007
Loading...

Share This Page