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

Delete LinkButton firing when Enabled = False

2 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kellie
Top achievements
Rank 1
Kellie asked on 05 Jan 2011, 08:58 PM
Im in version 2010.3.1215.35 using IE 8.

Even though I have disabled my Delete LinkButton in the ItemDataBound event, and it looks disabled, I am still able to click it, which prompts me with the delete comfirmation message. When I click to confirm, it deletes my record.

Here's my code behind where I disable the LinkButton

protected void RadGridWorkRequestAsset_ItemDataBound(object sender, GridItemEventArgs e)
{
            //Other code here
  
            if (e.Item is GridDataItem)
            {
                var editItem = ((GridDataItem)e.Item);
                var deleteButton = (LinkButton)editItem["DeleteColumn"].Controls[0];
  
                if (deleteButton != null)
                {
                    deleteButton.Enabled = false;
                }                 
             }
  
            //Other code here
}


Here's my LinkButton on the ASCX page:
<telerik:GridClientDeleteColumn ConfirmText="Delete this record?" ButtonType="LinkButton"  UniqueName="DeleteColumn" ConfirmTitle="Delete" ConfirmDialogType="Classic" CommandName="Delete">
</telerik:GridClientDeleteColumn>

I will also create a ticket so I can send you a small sample project to duplicate the problem.
Just posting for the forum users.

See attached screen shot.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Jan 2011, 07:05 AM
Hello Kellie,


I could replicate the issue in my end. Fortunately, I found a work-around for the issue. I am sharing the code.

Code:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        var editItem = ((GridDataItem)e.Item);
        var deleteButton = (LinkButton)editItem["DeleteColumn"].Controls[0];
        if (deleteButton != null)
        {
            deleteButton.Enabled = false;
            deleteButton.Attributes.Add("onclick", "JavaScript:void(0);");  // To prevent showing confirm for button
        }
    }
}



Thanks,
Princy.
0
Kellie
Top achievements
Rank 1
answered on 06 Jan 2011, 06:08 PM
Works Beautifully, thanks Princy - wish I could give you some Telerik points ;)
Tags
Grid
Asked by
Kellie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kellie
Top achievements
Rank 1
Share this question
or