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

Telerik.WebControls.GridInsertionObject error with property is an user class

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
t800t8
Top achievements
Rank 1
t800t8 asked on 05 Feb 2009, 04:42 AM
I found some information here http://www.telerik.com/community/forums/aspnet-ajax/grid/telerik-webcontrols-gridinsertionobject-error.aspx and here http://www.telerik.com/help/aspnet/grid/grderrormessages.html but they cannot help because my property is a class, not a primitive type.

My error message: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'Address'.

Is there anyway to bind a data class in insert mode?

                                <FormTemplate>     
                                    <table> 
                                        <tr> 
                                            <td> 
                                                Street: 
                                            </td> 
                                            <td> 
                                                <asp:TextBox ID="txtStreet" runat="server" Text='<%# Bind("Address.Street") %>' /> 
                                            </td> 
                                            <td> 
                                                City: 
                                            </td> 
                                            <td> 
                                                <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("Address.City") %>' /> 
                                            </td> 
                                            <td> 
                                                Zip: 
                                            </td> 
                                            <td> 
                                                <asp:TextBox ID="txtZip" runat="server" Text='<%# Bind("Address.Zip") %>' /> 
                                            </td> 
                                            <td align="right"
                                                <asp:LinkButton ID="btnUpdate" runat="server" CommandName="Update" Visible='<%# Eval("Id").ToString().Length != 0  %>'>Update</asp:LinkButton> 
                                                <asp:LinkButton ID="btnAdd" runat="server" CommandName="PerformInsert" Visible='<%# Eval("Id").ToString().Length == 0  %>'>Add</asp:LinkButton> 
                                                &nbsp;&nbsp;&nbsp; 
                                                <asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton> 
                                            </td> 
                                        </tr> 
                                    </table>                                 
                                </FormTemplate> 

2 Answers, 1 is accepted

Sort by
0
t800t8
Top achievements
Rank 1
answered on 05 Feb 2009, 04:56 AM
Actually, it helps :-)

        protected void rgUsers_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == RadGrid.InitInsertCommandName && e.Item.OwnerTableView.Name.Equals("Contacts")) 
            { 
                e.Canceled = true
 
                System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); 
                newValues["Address"] = new Address(); 
 
                e.Item.OwnerTableView.InsertItem(newValues); 
            } 
        } 

0
t800t8
Top achievements
Rank 1
answered on 05 Feb 2009, 06:19 AM
I still have a consideration. Why if I use a custom class, the problem happened but it didn't if I user primitive type?
Tags
Grid
Asked by
t800t8
Top achievements
Rank 1
Answers by
t800t8
Top achievements
Rank 1
Share this question
or