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

[Solved] Disable Edit/Delete Column in Edit/Insert Mode

2 Answers 580 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Softec
Top achievements
Rank 1
Softec asked on 24 Sep 2009, 11:42 AM
Hi

How can I disable the Edit and Delete Column if my RadGrid is in Edit or Insert Mode? I'm disabling the Refresh and AddNew Button OnItemDataBound but can't find the buttons for each row. 

At the moment I cancel the the event in the OnItemCommand handler but would like to give the user som visual hint (greyed out) that these buttons aren't working.

Thanks for advice!

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Sep 2009, 12:41 PM
Hello,

Tryout the following code in order to disable the Delete/Edit buttons (if it is AutoGenerated) when row in EditMode.

C#:
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    if (RadGrid1.EditIndexes.Count != 0 || RadGrid1.MasterTableView.IsItemInserted) 
    { 
        foreach( GridDataItem item in RadGrid1.MasterTableView.Items ) 
        { 
            LinkButton btnDelete = (LinkButton)item.FindControl("AutoGeneratedDeleteButton"); 
            btnDelete.Enabled = false
 
            LinkButton btnEdit = (LinkButton)item.FindControl("AutoGeneratedEditButton"); 
            btnEdit.Enabled = false
        } 
    } 

Try the code snippet in the following forum link if you are using LinkButton in TemplateColumn for deleting:
Delete link on radgrid performs delete function on edit mode

Thanks,
Princy.
0
Softec
Top achievements
Rank 1
answered on 29 Sep 2009, 10:51 AM
Thanks a lot!
Tags
Grid
Asked by
Softec
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Softec
Top achievements
Rank 1
Share this question
or