I have a problem when selecting the button to insert a new record in a grid containing a drop-down control. I'm not doing anything custom - all declaritive except for the code in the object data source controls. When I click the button on the details table to insert a new record, I get the following error:
DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'CountryCode'.
Note that if there is already data in the source database table for the details table, everything works fine. This only happens when there is no data in the database. I have been spending a long time on this and can't see what the issue is.
DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'CountryCode'.
Note that if there is already data in the source database table for the details table, everything works fine. This only happens when there is no data in the database. I have been spending a long time on this and can't see what the issue is.
<%@ Page Title="TMS Carrier" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"Server"
>
<
div
class
=
"gridHolderLarge"
>
<
h3
class
=
"tableDesc"
>
Carriers</
h3
>
<
telerik:RadGrid
ID
=
"grdCarrier"
runat
=
"server"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
DataSourceID
=
"objDataCarrier"
>
<
MasterTableView
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"CarrierId"
DataSourceID
=
"objDataCarrier"
EditMode
=
"InPlace"
NoMasterRecordsText
=
"No carriers to display."
>
<
DetailTables
>
<
telerik:GridTableView
runat
=
"server"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
DataSourceID
=
"objDataContact"
NoDetailRecordsText
=
"No contacts to display."
CommandItemDisplay
=
"Top"
DataKeyNames
=
"ContactId,CountryCode"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"CarrierId"
MasterKeyField
=
"CarrierId"
/>
</
ParentTableRelation
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
ExpandCollapseColumn
>
<
CommandItemSettings
AddNewRecordText
=
"Add new contact"
ShowRefreshButton
=
"False"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Contact Name"
MaxLength
=
"50"
UniqueName
=
"column4"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Position"
HeaderText
=
"Position"
MaxLength
=
"50"
UniqueName
=
"column5"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Phone"
HeaderText
=
"Phone"
MaxLength
=
"50"
UniqueName
=
"column6"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Address"
HeaderText
=
"Address"
MaxLength
=
"50"
UniqueName
=
"column7"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"City"
HeaderText
=
"City"
MaxLength
=
"50"
UniqueName
=
"column8"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"State"
HeaderText
=
"State/Province"
MaxLength
=
"50"
UniqueName
=
"column1"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PostalCode"
HeaderText
=
"Postal Code"
MaxLength
=
"30"
UniqueName
=
"column2"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DataField
=
"CountryCode"
DataSourceID
=
"objDataCountry"
HeaderText
=
"Country"
ListTextField
=
"Country"
ListValueField
=
"CountryCode"
UniqueName
=
"column"
DefaultInsertValue
=
"USA"
Visible
=
"False"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"Email"
HeaderText
=
"Email"
MaxLength
=
"200"
UniqueName
=
"column3"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Comment"
HeaderText
=
"Comment"
MaxLength
=
"4000"
UniqueName
=
"column10"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
CancelImageUrl
=
"~/images/Cancel.gif"
EditImageUrl
=
"~/images/Edit.gif"
InsertImageUrl
=
"~/images/Update.gif"
Reorderable
=
"False"
Resizable
=
"False"
UpdateImageUrl
=
"~/images/Update.gif"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
ConfirmDialogType
=
"RadWindow"
ConfirmText
=
"Are you sure you wish to permanently delete this contact?"
ConfirmTitle
=
"Delete Contact"
ImageUrl
=
"~/images/Delete.gif"
Reorderable
=
"False"
Resizable
=
"False"
Text
=
"Delete"
UniqueName
=
"column9"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
</
EditFormSettings
>
</
telerik:GridTableView
>
</
DetailTables
>
<
CommandItemSettings
AddNewRecordText
=
"Add new carrier"
/>
<
ExpandCollapseColumn
Visible
=
"True"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Carrier"
MaxLength
=
"50"
UniqueName
=
"column1"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"AccountNumber"
HeaderText
=
"Account Number"
MaxLength
=
"50"
UniqueName
=
"column2"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
CancelImageUrl
=
"~/images/Cancel.gif"
EditImageUrl
=
"~/images/Edit.gif"
InsertImageUrl
=
"~/images/Update.gif"
Reorderable
=
"False"
Resizable
=
"False"
UpdateImageUrl
=
"~/images/Update.gif"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
ConfirmDialogType
=
"RadWindow"
ConfirmText
=
"Do you wish to permanently delete this carrier?"
ConfirmTitle
=
"Delete Carrier"
ImageUrl
=
"~/images/Delete.gif"
Reorderable
=
"False"
Resizable
=
"False"
Text
=
"Delete"
UniqueName
=
"column"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
</
EditFormSettings
>
<
AlternatingItemStyle
BackColor
=
"#EAF2FA"
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:ObjectDataSource
ID
=
"objDataCarrier"
runat
=
"server"
DeleteMethod
=
"DeleteCarrier"
InsertMethod
=
"InsertCarrier"
OldValuesParameterFormatString
=
"original_{0}"
SelectMethod
=
"GetCarriers"
TypeName
=
"Carrier"
UpdateMethod
=
"UpdateCarrier"
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"original_CarrierId"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Name"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"AccountNumber"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"original_CarrierId"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Name"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"AccountNumber"
Type
=
"String"
/>
</
InsertParameters
>
</
asp:ObjectDataSource
>
<
asp:ObjectDataSource
ID
=
"objDataContact"
runat
=
"server"
OldValuesParameterFormatString
=
"original_{0}"
SelectMethod
=
"GetContacts"
TypeName
=
"CarrierContact"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"CarrierId"
Type
=
"Int32"
DefaultValue
=
""
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
<
asp:ObjectDataSource
ID
=
"objDataCountry"
runat
=
"server"
OldValuesParameterFormatString
=
"original_{0}"
SelectMethod
=
"GetCountries"
TypeName
=
"Country"
></
asp:ObjectDataSource
>
</
div
>
</
asp:Content
>