I'm using a RadGrid to insert/edit records. I'm using the FormTemplate. The problem I'm experiencing is that when you click on the Add A New Record button on the grid it doesn't expand to show the form template. Instead this error bubbles up: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'Address'.
I'm using an object datasource to populate the grid and do inserts and updates. Here's the data object I'm using:
And here's the form template I created for it.
I'm using an object datasource to populate the grid and do inserts and updates. Here's the data object I'm using:
public class Person : BusinessBase<
Person
>, IPerson, IAggregateRoot
{
public User.User Owner { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName
{
get { return LastName + ", " + FirstName; }
}
public DateTime BirthDate { get; set; }
public Address.Address Address { get; set; }
public IList<
Item.Item
> Items { get; set; }
protected override void validate()
{
}
}
public class Address : BusinessBase<
Address
>, IAddress, IAggregateRoot
{
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
protected override void validate()
{
}
}
And here's the form template I created for it.
<
EditFormSettings
EditFormType
=
"Template"
InsertCaption
=
"New Person"
>
<
FormTemplate
>
<
div
id
=
"PersonDiv"
>
<
table
>
<
tr
>
<
td
>
First Name:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtFirstName"
MaxLength
=
"50"
Text='<%# Bind("FirstName") %>' />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ControlToValidate
=
"txtFirstName"
ErrorMessage
=
"A first name is required"
ValidationGroup
=
"vgPerson"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
Last Name:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtLastName"
MaxLength
=
"50"
Text='<%# Bind("LastName") %>' />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ControlToValidate
=
"txtLastName"
ErrorMessage
=
"A last name is required"
ValidationGroup
=
"vgPerson"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
Use your address:
</
td
>
<
td
>
<
telerik:RadButton
ToggleType
=
"CheckBox"
runat
=
"server"
ID
=
"cbUseYourAddress"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
Street:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtStreet"
MaxLength
=
"50"
Text='<%# Bind("Address.Street") %>' />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ControlToValidate
=
"txtStreet"
ErrorMessage
=
"A street is required"
ValidationGroup
=
"vgPerson"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
City:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtCity"
MaxLength
=
"50"
Text='<%# Bind("Address.City") %>' />
</
td
>
</
tr
>
<
tr
>
<
td
>
State:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtState"
MaxLength
=
"2"
Text='<%# Bind("Address.State") %>' />
</
td
>
</
tr
>
<
tr
>
<
td
>
Zip code:
</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtZipCode"
MaxLength
=
"10"
Text='<%# Bind("Address.ZipCode") %>' />
</
td
>
</
tr
>
<%-- <
tr
>
<
td
>
Birth date:
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"dpBirthDate"
runat
=
"server"
DbSelectedDate='<%# Bind("BirthDate") %>' />
</
td
>
</
tr
>--%>
<
tr
>
<
td
colspan
=
"2"
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' ValidationGroup="vgPerson" />
<
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
ValidationGroup
=
"vgPerson"
/>
</
td
>
</
tr
>
</
table
>
</
div
>
<
asp:ValidationSummary
ID
=
"ValidationSummary1"
runat
=
"server"
ValidationGroup
=
"vgPerson"
ShowMessageBox
=
"True"
ShowSummary
=
"False"
/>
</
FormTemplate
>
When I'm referencing the address information in the Bind I have to use 'Address.Street' in order to get to the street field of the Address object. Same format for the other fields in the address object. It would seem the form template doesn't like that. Any suggestions would be very much appreciated.