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

Init Insert button ( Add new record )

3 Answers 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Nagy
Top achievements
Rank 2
Michael Nagy asked on 02 Mar 2009, 09:27 AM
Hello ,
 i used RadGrid and using need data source for binding grid , i used commandItems ( insert , .. ) and i am using automatic  edit form template .
i want not to allow user to click add new record when the grid in edit mode
(i.e.) i want to disable add new record button when the grid in edit mode.

 <MasterTableView GridLines="None" CommandItemDisplay="Top"

could you help me please to find a solution for this issue .


3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Mar 2009, 09:47 AM
Hi Michael,

Try the following code snippet and see if it is helpful.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
    if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))  
    {  
        foreach (GridCommandItem cmdItm in RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem))  
        {  
            LinkButton Addbtn = (LinkButton)cmdItm.FindControl("InitInsertButton");  
            Addbtn.Enabled = false;        
        }  
    }   

Thanks,
Princy.
0
Michael Nagy
Top achievements
Rank 2
answered on 02 Mar 2009, 12:19 PM
thanks so your rabidly reply ,
  but i have anothor question .. 
   i used automatic update delete i need to disable Edit link for this item  when it is in Edit mode . how can i do this ?
0
Shinu
Top achievements
Rank 2
answered on 03 Mar 2009, 07:23 AM
Hi Michael,

I guess you are trying to disable the Edit button of a Grid row when it is in edit mode. If so you can try the following code snippet in the ItemDataBound event.

CS:
   protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditFormItem editItem = (GridEditFormItem)e.Item; 
            GridDataItem item = (GridDataItem)editItem.ParentItem; 
            LinkButton lnkbtn = (LinkButton)item["EditCol"].Controls[0]; 
            lnkbtn.Enabled = false
        } 
    } 

Regards
Shinu



Tags
Grid
Asked by
Michael Nagy
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Michael Nagy
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or