Reputation: 5972
I have a Telerik RadGrid which uses the EditFormSettings like this:
<EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/MyUserControl.ascx" >
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
Within MyUserControl.ascx, I have a button which I'd like to trigger an event handler when clicked. The two ways I know of doing this are as follows:
OnClick="btnOkay_Click"
as a button attribute, where the event handler is in the code behindCommandName="Update"
as a button attribute, where this is handled by the event handler passed into the OnUpdateCommand attribute of the RadGridBoth of these work. However my problem is that they stop working when the RadGrid is within a user control within a Repeater
ASP.NET control. In this case, the button event handlers do not get fired (in either of the methods above).
I notice that when I bind my repeater:
rpt.DataSource = Data
rpt.DataBind()
If I wrap that in a if(!Page.IsPostBack)
, then the edit form doesn't appear at all when I click on the RadGrid row's edit link. So I had to remove that IsPostBack
check. I don't think think this is the cause of my problem, as I've tried explicitly not doing this when clicking my update button (by breaking into the debugger). I just thought I'd mention it incase it was related.
Can anyone think of a reason why this would break in a Repeater?
Upvotes: 1
Views: 960
Reputation: 5972
Found the problem with a little help from a work colleague! Turned out to be because I was binding the Repeater
in Page_Load
rather than Page_Init
. Changing it to Page_Init
resolved the issue.
Upvotes: 1