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

DataBinding: 'Telerik.WebControls.GridInsertionObject' does not contain a property with the name

2 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 08 Sep 2008, 06:27 AM

Hello,

In my grid, I have a user control that provides functionality for my insert/updates.  I am getting the all too famous error:

"DataBinding: 'Telerik.WebControls.GridInsertionObject' does not contain a property with the name"

Now,  in my code I have so far been successful with this issue by using the following coding:

protected

void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)

{

if (e.CommandName == RadGrid.InitInsertCommandName)

{

e.Canceled =

true;

ListDictionary newValues = new ListDictionary();

newValues[

"BudgetWSTypeID"] = string.Empty;

newValues[

"ProgramNameID"] = string.Empty;

newValues[

"FiscalYearID"] = string.Empty;

ECT.....


However, if you look at the below control (where the problem is occuring), you will notice that the selected value is coming from "DataItem.Grantee.GranteeID" --  how do I add this to my listDictionary for this to work?  Perhaps I need to use a different object? 



<

rad:RadComboBox selectedvalue='<%# DataBinder.Eval( Container, "DataItem.Grantee.GranteeID") %>' MarkFirstMatch="true"

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Sep 2008, 07:51 AM
Hi John,

To avoid this error you can set the AppendDataBoundItems property to true for RadComboBox and include an empty item to its Items collection. Refer to the following documentation link to get more information on this.
Known reasons for error messages

Also, try binding the grid using AdvanceDataBindingTechniques.

Thanks
Princy.
0
john
Top achievements
Rank 1
answered on 09 Sep 2008, 07:49 AM
Thanks, however the info on that page that appears to possibly address says "For custom edit forms (WebUserControl/FormTemplate) you can refer to the last paragraph in this help topic. " however, the link shown is bad. 


Perhaps I could offer more clarity on the problem:

I know what the problem is, but I am not sure how to remedy the problem using the rad grid control--with usercontrol for insert/updates.

Like most user controls in the radgrid, they employ databinding such as here:

<%# DataBinder.Eval( Container, "DataItem.UserID") %>

Now, for inserts, the above line of code in my user control would fail, however, we are instructed to use hash tables (or dictionary object) to resolve this problem.  And thus I wrote the code:

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)

{

if (e.CommandName == RadGrid.InitInsertCommandName)

{

e.Canceled =

true;

ListDictionary newValues = new ListDictionary();

newValues[

"UserID"] = string.Empty;
...

So far everything works good.


However,
the below binding code uses an object within an object: Grantee.GranteeID.  So, in the datasource, there is a collection where one of the properties is a user-defined object of type Grantee.  (once again, this line of code works in edit mode, but fails in insert mode).

<%# DataBinder.Eval( Container, "DataItem.Grantee.GranteeID") %>

So, I tried the following solution, but this throws an error (see error below as well).   How does one create a dummy record for inserts WHEN using user-defined objects in a collection?  Any ideas?  Really stuck on this one...thanks.

PropertyCollection newValues = new PropertyCollection();

Grantee grantee = new Grantee();

newValues.Add(

"Grantee", grantee);

newValues.Add(

"UserID", string.Empty);

e.Item.OwnerTableView.InsertItem(newValues);


 

Selection out of range
Parameter name: value

e.Item.OwnerTableView.InsertItem(newValues);

Tags
Grid
Asked by
john
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
john
Top achievements
Rank 1
Share this question
or