This is a migrated thread and some comments may be shown as answers.

Set a GridButtonColumn invisible

2 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adigard
Top achievements
Rank 1
Adigard asked on 03 Nov 2011, 10:42 AM
Greetings,

I'd like to set a GridButtonColumn invisible in the case the user does not have the rights to delete a row ( for instance )

The GridButtonColumn is declared like this:

<telerik:GridButtonColumn CommandName="Delete" Text="Supprimer" UniqueName="column2">
</telerik:GridButtonColumn>


The condition is this one :
string req = " SELECT rights from utilisateur WHERE login = '" + login + "'";
int test = DA.DAConnexion.executeQueryScalar(req);
Session["rights"] = test;
if Session["rights"] gets the value 0, the GridButtonColumn must not be visible


Thanks in advance for your help

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Nov 2011, 10:53 AM
Hello,

<telerik:GridButtonColumn CommandName="Delete" Text="Supprimer" UniqueName="column2"
                             >
                    </telerik:GridButtonColumn>
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["rights"] != null)
        {
            if (Session["rights"].ToString() == "0")
            {
                RadGrid2.MasterTableView.GetColumn("column2").Visible = false;
  
            }
        }
    }

Note : if you faced any problem then try above code in Page_Prerender or Grid_Prerener.

Method 2 :
if (RadGrid2.MasterTableView.Columns.FindByUniqueName("column2") != null)
        {
            RadGrid2.MasterTableView.Columns.FindByUniqueName("column2").Visible = false;
        }


Thanks,
Jayesh Goyani
0
Adigard
Top achievements
Rank 1
answered on 03 Nov 2011, 11:43 AM
It works perfectly, thanks again for your help!
Tags
Grid
Asked by
Adigard
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Adigard
Top achievements
Rank 1
Share this question
or