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

RadGrid - EditForm events when RadGrid is inside Repeater

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 09 Sep 2014, 12:45 PM
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:

1.  `OnClick="btnOkay_Click"` as a button attribute, where the event handler is in the code behind
2.  `CommandName="Update"` as a button attribute, where this is handled by the event handler passed into the OnUpdateCommand attribute of the RadGrid

Both 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?

1 Answer, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 09 Sep 2014, 01:46 PM
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.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Share this question
or