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

Object of type 'Telerik.Web.UI.GridDataItem' cannot be converted to type 'Sys.UI.Control'.

2 Answers 346 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leander
Top achievements
Rank 1
Leander asked on 26 Jun 2013, 08:05 AM
Hallo, 

I made a page with a radgrid on it. At first the page had a asp script manager. But when i put in an RadAjaxLoadingPanel it gave the error
"A control is already associated with the element." After looking on the internet I found a solution. I replaced the script manager in my master layout with the radscriptmanager. I registered it both for IIS6 and IIS7. Now when i load the grid it still shows but when i want to do anything with it, it gives the error. "Object of type 'Telerik.Web.UI.GridDataItem' cannot be converted to type 'Sys.UI.Control'". 
It gives the error when I try to use any feature of the grid. When i use a button in the command bar, after doing the onclick, it gives the error. When i try to edit a record, it gives the error. After giving the error the grid stops working. 

<asp:EntityDataSource ID="edsBackups" runat="server" EntitySetName="Backups" ConnectionString="name=ControlwareEntities"
        DefaultContainerName="ControlwareEntities" EnableFlattening="False" EnableUpdate="True"
        EntityTypeFilter="" OrderBy="it.DateTime DESC" Select="">
    </asp:EntityDataSource>
   
    <telerik:RadGrid runat="server" ID="cg" DataSourceID="edsBackups" OnUpdateCommand="cg_UpdateCommand"
        OnDeleteCommand="cg_DeleteCommand"
         
        AllowPaging="True"
        AllowSorting="True"
        >
        <MasterTableView DataKeyNames="ID">
            <CommandItemTemplate>
                <div style="padding: 5px 5px;">
                    <asp:LinkButton ID="LinkButton2" runat="server" OnClick="bBackup_OnClick"><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_342_hdd.png"/> <asp:Literal ID="Literal1" meta:resourcekey="NewBackup" runat="server" Text="New"></asp:Literal></asp:LinkButton>  
                    <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected"><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_030_pencil.png" /> <asp:Literal ID="Literal2" meta:resourcekey="EditBackup" runat="server" Text="Edit"></asp:Literal></asp:LinkButton>  
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_016_bin.png"/> <asp:Literal ID="Literal3" meta:resourcekey="DeleteBackup" runat="server" Text="Delete"></asp:Literal></asp:LinkButton>  
                    <asp:LinkButton ID="LinkButton5" runat="server" OnClick="bRestore_OnClick"><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_082_roundabout.png"/> <asp:Literal ID="Literal4" meta:resourcekey="RestoreBackup" runat="server" Text="RestoreBackup"></asp:Literal></asp:LinkButton>  
                    <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><div style="float:right"><img style="border:0px;vertical-align:middle" alt="" width="15" src="/Styles/glyphicons/glyphicons_081_refresh.png"/> <asp:Literal ID="Literal5" meta:resourcekey="RefreshBackup" runat="server" Text="Refresh"></asp:Literal></asp:LinkButton>
                </div>
            </CommandItemTemplate>
            <EditFormSettings EditFormType="Template" InsertCaption="New" CaptionFormatString="Edit">
                <FormTemplate>
                    <div style="padding: 5px">
                        <table id="Table2" width="100%" border="0" style="border-collapse: collapse; padding: 5px">
                            <tr>
                                <td colspan="2"><b>Backup:</b></td>
                            </tr>
                            <tr>
                                <td>Created On:</td>
                                <td><asp:Label runat="server" Text='<%# Eval("DateTime") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td>Name:</td>
                                <td><asp:TextBox ID="TextBox1" Style="width: 200px;" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox></td>
                            </tr>
                            <tr>
                                <td>
                                    Full Backup:
                                </td>
                                <td>
                                    <asp:CheckBox Enabled="False" runat="server" ID="cb1" Checked='<%# Bind("IsFullBackup") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="padding: 5px">
                                    <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# cg.EditIndexes.Count > 0 || cg.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_221_unshare.png"/> Cancel</asp:LinkButton>  
                                    <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# cg.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt=""  width="15" src="/Styles/glyphicons/glyphicons_003_user.png"/> Update</asp:LinkButton>  
                                </td>
                            </tr>
                        </table>
                    </div>
                </FormTemplate>
            </EditFormSettings>
            <Columns>
                <telerik:GridBoundColumn HeaderText="ID" DataField="ID" Visible="False" />
                <telerik:GridBoundColumn meta:resourcekey="GridColumn1" HeaderText="Timestamp" DataField="DateTime" />
                <telerik:GridBoundColumn meta:resourcekey="GridColumn2"  HeaderText="Name" DataField="Name" />
                <telerik:GridCheckBoxColumn meta:resourcekey="GridColumn3" HeaderText="Full Backup" DataField="IsFullBackup" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

I also found out that it gives the same error with the raddropdownlist

2 Answers, 1 is accepted

Sort by
0
Johny
Top achievements
Rank 1
answered on 28 Jun 2013, 08:02 AM
Hallo

I suspects the problem in your code behind code. Maybe if you provide your codes I can help.

Cheers,
Johny
0
Leander
Top achievements
Rank 1
answered on 28 Jun 2013, 08:41 AM
It turned out that I by put my radscriptmanager inside a updatepanel. 
WHen i took it out it worked again. 
Tags
Grid
Asked by
Leander
Top achievements
Rank 1
Answers by
Johny
Top achievements
Rank 1
Leander
Top achievements
Rank 1
Share this question
or