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

Disabled GridButtonColumn Confirm Dialog Issue

2 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mehmet Emrah
Top achievements
Rank 1
Mehmet Emrah asked on 13 Jan 2011, 10:27 AM
I am using radgrid in my project, i have a strange issue about confirmation dialog,
below is a sample code from one of my aspx page...

<telerik:GridButtonColumn CommandName="Delete" HeaderStyle-Width="30px" Text="Delete" UniqueName="columnButtonDelete"   ConfirmDialogType="RadWindow" ConfirmText="Are you sure to delete the record?" ConfirmTitle="Confirm Delete">
</telerik:GridButtonColumn>

the confirmation dialog window opens and works as expected, no problem...

However, some records should be disabled for deleting, when I disable those records from code-behind (inside ItemDataBound event of the gridview) like:

CType(DataItem("columnButtonDelete").Controls(0), LinkButton).Enabled = False

The button is disabled, no problem... But a user still can click on that button and the confirmation dialog pop-ups!?
If the user clicks on 'Yes' to try deleting the record, the confirmation window closes, but the record is not being deleted...

Is it a bug? How can i prevent a disabled button to be clicked?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Jan 2011, 10:46 AM
Hello Mehmet,

You can avoid this by disabling the delete item - on a per cell basis like below.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem DataItem = (GridDataItem)e.Item;
           TableCell cell = (TableCell)DataItem["columnButtonDelete"];
           cell.Enabled = false;
       }
   }

Thanks,
Princy.
0
Mehmet Emrah
Top achievements
Rank 1
answered on 13 Jan 2011, 01:24 PM
It works! Thanks...
Below is working vb code...
CType(DataItem("columnButtonDelete"), TableCell).Enabled = False
Tags
Grid
Asked by
Mehmet Emrah
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mehmet Emrah
Top achievements
Rank 1
Share this question
or