I am having a problem inserting records on a Sub heirarchial grid. If no dta exists it errors our the bind function for the editing. But if existing data is loaded for that sub grid the insert works just fine. So on insert of the datatable has nothing in it it will error out on the 1st textbox that is bound to data from datatable and give the follwoing error. But the problem is the field is there becuase it works for other rows with data. If you manually insert record, it will work fine. What is the work around to this.
DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'strDescription'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'strDescription'.
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
style
=
"width:100%;background-color:antiquewhite"
>
<
tr
>
<
td
style
=
"height:10px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:10%;text-align:right"
>Position Description: </
td
>
<
td
style
=
"width:90%;text-align:left"
><
asp:TextBox
ID
=
"txtdescription"
runat
=
"server"
Width
=
"200px"
Text='<%#Bind("strDescription") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:10px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:10%;text-align:right"
>Position Scale: </
td
>
<
td
style
=
"width:90%;text-align:left"
><
asp:TextBox
ID
=
"txtScale"
runat
=
"server"
Width
=
"200px"
Text='<%#Bind("strScale") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:10px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:10%;text-align:right"
>Position Type: </
td
>
<
td
style
=
"width:90%;text-align:left"
><
asp:TextBox
ID
=
"txtPosType"
runat
=
"server"
Width
=
"200px"
Text='<%#Bind("strPositionType") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:10px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:10%;text-align:right"
>Position Grade: </
td
>
<
td
style
=
"width:90%;text-align:left"
><
asp:TextBox
ID
=
"txtGrade"
runat
=
"server"
Width
=
"200px"
Text='<%#Bind("strGrade") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:5px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:10%;text-align:right"
></
td
>
<
td
style
=
"width:90%;text-align:left"
>
<
asp:LinkButton
ID
=
"lnkSubmit"
runat
=
"server"
Text='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "Insert" : "Update" %>'
CommandName='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "PerformInsert" : "Update" %>'>
</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkCancel"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"Cancel"
Text
=
"Cancel"
></
asp:LinkButton
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
if (e.CommandName == RadGrid.PerformInsertCommandName && e.Item.OwnerTableView.Name == "Positions")
{
GridEditableItem item = e.Item as GridEditableItem;
GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
//int sectionId = Convert.ToInt32(item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["intSectionId"]);
int secId = Convert.ToInt32(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["intSectionId"]);
TextBox descrip = (TextBox)item.FindControl("txtdescription");
TextBox scale = (TextBox)item.FindControl("txtScale");
TextBox posType = (TextBox)item.FindControl("txtPosType");
TextBox grade = (TextBox)item.FindControl("txtGrade");
sql = "Execute usp_InsertPosition " + secId + ", '" + c.SanitizeString(descrip.Text) + "', '" + c.SanitizeString(scale.Text) + "', '" + c.SanitizeString(posType.Text) + "', '" + c.SanitizeString(grade.Text) + "'";
c.InsertUpdateDelete(sql);
// myradGrid.Rebind();
}