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

Set Enable = False for Grid columns.

1 Answer 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Guruvu
Top achievements
Rank 1
Guruvu asked on 15 Feb 2011, 12:09 PM
Hi,

In my Rad Grid,for editing & deleting i am using GridEditCommandColumn,GridButtonColumn. I need to set these 2 columns enabled=false after binding data to RadGrid.

Here is my code :
<telerik:GridEditCommandColumn ButtonType="ImageButton" 
                                 HeaderStyle-HorizontalAlign="Left" HeaderText="Edit" 
                                 ItemStyle-HorizontalAlign="Left">
                                 <HeaderStyle HorizontalAlign="Left" />
                                 <ItemStyle HorizontalAlign="Left" />
</telerik:GridEditCommandColumn>
  
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" 
                                 ConfirmDialogHeight="100px" ConfirmDialogType="RadWindow" HeaderText="Delete"
                                 ConfirmDialogWidth="220px" 
                                 ConfirmText="Are you sure you want to delete this Indent Item?" ConfirmTitle="Delete" 
                                 HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="NotSet" 
                                 ItemStyle-HorizontalAlign="Left">
                                 <HeaderStyle HorizontalAlign="Left" />
                                 <ItemStyle HorizontalAlign="Left" />
</telerik:GridButtonColumn>
 
How to achieve this requirement.Please help me...

Thanks in advance...

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Feb 2011, 12:57 PM
Hello,
You can try the following code snippet in the PreRender Event.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
 {
     foreach (GridDataItem item in RadGrid1.MasterTableView.GetItems(GridItemType.Item))
     {
        ImageButton btn1 = (ImageButton)item.FindControl("gbcDeleteColumn");//accessing the Button by its name
        btn1.Enabled = false;
        ImageButton btn2 = (ImageButton)item.FindControl("EditButton");
        btn2.Enabled = false;
     }
 }

And also set the UniqueName for the GridButtonColumn as DeleteColumn

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