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

Disable Insert/Update In Edit Mode

2 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Baatezu
Top achievements
Rank 2
Baatezu asked on 21 Oct 2008, 08:25 PM
Is it possible to disable/hide/remove/make unusable/ect the Insert and Update control in edit mode?
If it is possible, a pointer to a place to look or a quick code sample would be great. :)

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Oct 2008, 04:47 AM
Hi,

Try the following code snippet to hide the CommandItem containing the AddNewRecord button when the Grid is in edit mode.

CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Edit") 
        { 
            RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; 
        } 
        else 
          RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top; 
   } 


Thanks
Shinu.
0
Baatezu
Top achievements
Rank 2
answered on 22 Oct 2008, 04:52 AM
Thanks for the response, I was looking to turn off the ability to update some of the records.

I found a solution with the help of this (http://www.telerik.com/help/aspnet/grid/grdupdatinginplaceandeditforms.html) article.

protected void grdDetails_ItemCreated(object sender, GridItemEventArgs e)
{
foreach (GridDataItem item in grdDetails.EditItems)
{
GridEditableItem itemToEdit = (item.OwnerTableView.EditMode == GridEditMode.InPlace) ? (GridEditableItem)item : (GridEditableItem)item.EditFormItem;

if (itemToEdit.FindControl("UpdateButton") != null && ((CheckBox)itemToEdit.FindControl("chkLocked")).Checked)
{
itemToEdit.FindControl("UpdateButton").Visible = false;
}
}
}

(code block wasn't working for me)
chkLocked is what I use to determine if it should show or not.
Tags
Grid
Asked by
Baatezu
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Baatezu
Top achievements
Rank 2
Share this question
or