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

Error when trying to ajaxify templated GridView buttons

2 Answers 62 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Ron Cirka
Top achievements
Rank 1
Ron Cirka asked on 16 Sep 2009, 04:19 PM
I am trying to ajaxify links in a gridview. When I add the OnItemCreated event hander, I get the error:

Collection was modified; enumeration operation may not execute.


I have predefined AjaxSettings in the RadAjaxManager. I found that if I remove them, I don't get the error. Shouldn't it be possible to have defined ajax settings as well as dynamically added them in code behind?

protected void uxGrid_OnItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            LinkButton lnkAddParticipant = (LinkButton)item["TemplateColumn"].FindControl("lnkAddParticipant"); 
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(lnkAddParticipant, uxGrid, null); 
        } 
    } 

This works:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
        <AjaxSettings> 
</AjaxSettings> 
    </telerik:RadAjaxManager> 

This doesn't work:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="btnLoadRooms"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="uxGrid" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
</AjaxSettings> 
    </telerik:RadAjaxManager> 



2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 21 Sep 2009, 07:46 AM
Hello Ron,

It is not suggested practice to ajaxify only a link button which is in any GridColumn. To achieve the desired functionality you should ajaxify the whole RadGrid or the parent that hold it. For example:  
RadAjaxManager1.AjaxSettings.AddAjaxSetting(uxGrid, uxGrid, null);

Please give this suggestion a try and let me know if it works for you.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ron Cirka
Top achievements
Rank 1
answered on 24 Sep 2009, 02:15 PM
Unfortunately if I ajax the whole grid, it causes an ajax error when updating a component I built. I changed the functionality on the grid to work around, so it's no longer an issue.
Tags
Ajax
Asked by
Ron Cirka
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ron Cirka
Top achievements
Rank 1
Share this question
or