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

Hide EditCommandColumn

2 Answers 441 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SKY
Top achievements
Rank 1
SKY asked on 31 Oct 2010, 07:43 AM
Hi,

I am using telerik rad grid for displaying data.
For editing, i am using GridEditCommandColumn for displaying the edit option.
Now based on some logic, i have to hide/show this "Edit" option based on some value coming from the database.
Currently i am trying to do this in ItemDataBound event -
((Telerik.Web.UI.GridEditCommandColumn)(e.Item.OwnerTableView.Columns[0])).Visible = false;
It is hiding the complete column. What i thought was, it will hide the Edit option for the particular row but it hides the column itself.
I also tried to set the EditText property to set it to blank based on condition, but the results were coming awkward, like it was showing or hiding Edit option randomly.
(((Telerik.Web.UI.GridEditCommandColumn)(e.Item.OwnerTableView.Columns[0])).EditText = "Edit";)

Is there any way i can hide the GridEditCommandColumn Edit option for a particular row.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Nov 2010, 05:55 AM
Hello,

Try the following method to hide the Edit button for some rows.

ASPX:
<telerik:GridEditCommandColumn UniqueName="GridEditCommandColumn">
</telerik:GridEditCommandColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           LinkButton editButton = (LinkButton)item["GridEditCommandColumn"].Controls[0];
           if (//your condition)
           {
               editButton.Visible = false;
           }
       }
   }

Thanks,
Princy.
0
SKY
Top achievements
Rank 1
answered on 01 Nov 2010, 05:34 PM
Hi Princy,

Thank you very much.
That was exactly what i was looking for.

SKY
Tags
Grid
Asked by
SKY
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
SKY
Top achievements
Rank 1
Share this question
or