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

Add button to radgrid footer

2 Answers 530 Views
Grid
This is a migrated thread and some comments may be shown as answers.
weezie
Top achievements
Rank 1
weezie asked on 03 Jan 2011, 09:01 PM

I am trying to add an .net button dynamically to the radgrid footer with the following code.  The button gets displayed correctly.
However, the btn_Click event does not get fired when the button is clicked.
Am I missing something in the code?

Thanks for your help.

  protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
        if (e.Item is GridFooterItem)  
        {  
            GridFooterItem footerItem = (GridFooterItem)e.Item;  
            RadScriptManager1.RegisterAsyncPostBackControl(btn);
            Button btn = new Button();  
            btn.Text = "Button";  
            btn.Click += new System.EventHandler(btn_Click);
            footerItem.Cells[2].Controls.Add(btn);  
        }  
    }  

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Jan 2011, 10:58 PM
Hello Weezie,

Your code works as expected on my end. Please examine the attached project and let me know if your scenario is different.

Kind regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
weezie
Top achievements
Rank 1
answered on 05 Jan 2011, 07:02 PM
Yes, its working.  I think I must have still been hungover from New Years because
I had

 

OnItemDataBound="RadGrid1_ItemCreated"

instead of

 

 

 

OnItemCreated

 

="RadGrid1_ItemCreated"\


thanks for your help.

 

Tags
Grid
Asked by
weezie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
weezie
Top achievements
Rank 1
Share this question
or