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

Button click event not fired for a GridGroupHeader Item

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sangeetha Ayyappan
Top achievements
Rank 1
Sangeetha Ayyappan asked on 24 Mar 2010, 01:15 PM
Hi,

After a very long struggle, I managed to get buttons on my grid group headers. (Still there is an issue with it, like a postback making the controls to  vanish - Anyway, I'll look into it later) As of now, I've added buttons to the group header items and also I have defined an event-handler for the button click event.

Please see my code below for the radgrid_ItemDataBound event

if

 

(e.Item is GridGroupHeaderItem)

 

{

     

           Button

 

btnModifyStrategy = new Button();

 

           btnModifyStrategy.Text =

"Modify Strategy";

 

           btnModifyStrategy.CssClass =

"tab4-sub1btn";

 

 

            //btnModifyStrategy.UseSubmitBehavior = false;

 

           btnModifyStrategy.Click +=

new EventHandler(btnModifyStrategy_Click);

 

          groupheader.DataCell.Controls.Add(btnModifyStrategy);

}


The button is added to the group header now. But when I click on the button, the button click event is not fired. Its driving me too crazy as I've been into this problem since this morning.

Can you advise me on this?

Thanks in advance.

Sangeetha


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Mar 2010, 02:16 PM
Hello Sangeetha Ayyappan,

 If you need to add controls to a grid item that should fire a postback event, you should create the controls in ItemCreated event handler rather than ItemDataBound.
Distinguishing the major differences between ItemCreated and ItemDataBound events

Regards,
Princy.
Tags
Grid
Asked by
Sangeetha Ayyappan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or