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

Disable insert and delete on EditForm

2 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dick
Top achievements
Rank 1
Dick asked on 28 Aug 2008, 08:07 PM

I have read thru other forum responses to this question and have used the following code which i found in forum responses.

protected

void RiskIdentificationGrid_ItemDataBound(object source, GridItemEventArgs e) //GridItemEventArgs e)
{
    
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
         {
              
GridCommandItem cmditm = (GridCommandItem)e.Item;
               
LinkButton updateButton = (LinkButton)cmditm.FindControl("UpdateButton");
               updateButton.Visible =
false;

               

LinkButton lnkbtn1 = (LinkButton)cmditm.FindControl("InitInsertButton");
                lnkbtn1.Visible =
false;

                Button btn1 = (Button)cmditm.FindControl("AddNewRecordButton");
                btn1.Visible =
false;
           }
}

However, when I try to run, I get the following compile error...............

        No overload for 'RiskIdentificationGrid_ItemDataBound' matches
delegate 'System.EventHandler'

I have spent many hours trying to figure out why this is happening.  Am I missing something, and how can I resovle this.

I am using VS 2008,  RadControls for ASP.NET AJAX 3.5 and C#.

Thanks for your help.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Aug 2008, 05:45 AM
Hi Dick,

Try setting the visibility of the Insert button in edit mode as shown below.

CS:
  protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
            { 
                foreach (GridCommandItem item in RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)) 
                { 
                    Button btn1 = (Button)item.FindControl("AddNewRecordButton"); 
                    btn1.Visible = false
                    // To disable the LinkButton 
                    LinkButton lnkbtn1 = (LinkButton)item.FindControl("InitInsertButton"); 
                    lnkbtn1.Visible = false
                } 
            } 
   } 


Thanks
Shinu.
0
Dick
Top achievements
Rank 1
answered on 29 Aug 2008, 01:21 PM
Thanks for your response.  I used the example you sent with the fully qualified 

RiskIdentificationGrid1_ItemDataBound(

object source, Telerik.Web.UI.GridItemEventArgs e)

and still recieved the compile error stating. 

No overload for 'RiskIdentificationGrid_ItemDataBound' matches delegate 'System.EventHandler'

Any other suggestions?

Tags
Grid
Asked by
Dick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dick
Top achievements
Rank 1
Share this question
or