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

How to disable the editbutton per row

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ruud
Top achievements
Rank 1
Ruud asked on 22 Jul 2010, 08:58 AM
Hi,

I have a radgird with (say) 10 rows.
I want to make the first 4 rows not editable, so the edit and the delete buttons should not be visible for these four rows, but visible for the remaining 6 rows. I cannot find how to do this on a row basis.

Regards,
-Ruud

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2010, 10:02 AM
Hello Ruud,

You can try the following code snippet to hide the Edit and Delete Button for first four rows in a grid.

ASPX:
<telerik:GridButtonColumn CommandName="Edit" ButtonType="LinkButton" UniqueName="editBtn"
    Text="Edit">
</telerik:GridButtonColumn>
<telerik:GridButtonColumn CommandName="Delete" ButtonType="LinkButton" UniqueName="deleteBtn"
    Text="Delete">
</telerik:GridButtonColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = e.Item as GridDataItem;
           if (item.ItemIndex < 4)
           {
               LinkButton editBtn = (LinkButton)item["editBtn"].Controls[0];
               editBtn.Visible = false;
               LinkButton deleteBtn = (LinkButton)item["deleteBtn"].Controls[0];
               deleteBtn.Visible = false;
           }
       }
  }

Thanks,
Princy.
Tags
Grid
Asked by
Ruud
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or