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

'Telerik.WebControls.GridInsertionObject Error

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan Vogt
Top achievements
Rank 1
Brendan Vogt asked on 25 Aug 2008, 08:47 AM
Hi,

I have the following piece of code:

<radG:GridDropDownColumn
   DataSourceID="odsTitles"
   ListTextField="Description"
   ListValueField="TitleID"
   DataField="Title.Description"
   UniqueName="TitleDescription"
   HeaderText="Title">
</radG:GridDropDownColumn>

Here is my object datasource:

<asp:ObjectDataSource
   ID="odsTitles"
   TypeName="MyBank.Lookup.TitleManager"
   SelectMethod="GetTitles"
   runat="server">
</asp:ObjectDataSource>

My first question is:

If the grid displays all the rows, my title is not set to the title which is in my table, it seems to select the first item in the title dropdown list.

Second question, when I click on add new record, then I get the following error.

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

The current grid loads a whole lot of Communication objects.  In the Communication class I have a reference to the Title class.

Please can someone help me?

Thanks
Brendan

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 09:34 AM
Hi Brendan.

2. Error message "Telerik.WebControls.GridInsertionObject does not contain a property with the name <some_name>"

   The reason for this error is that your grid instance can not bind a value for the newly inserted item through the Eval()/Bind() syntax you hard-coded (as you may have seen from the stack trace of the error).

 Go through the following help article which explains the ways in which this error can be fixed.
Known reasons for error messages

Thanks
Shinu.

0
Brendan Vogt
Top achievements
Rank 1
answered on 25 Aug 2008, 10:02 AM
Thanks.  I have added the following code:

<EditFormSettings EditFormType="Template">
   <FormTemplate>
      <table border="1" cellpadding="0" cellspacing="0" width="100%">
         <tr>
            <td>Title</td>
            <td>
               <asp:DropDownList
                  ID="ddlTitles"
                  AppendDataBoundItems="true"
                  DataSourceID="odsTitles"
                  DataTextField="Description"
                  DataValueField="TitleID"
                  runat="server">
               </asp:DropDownList>
            </td>
         </tr>
      </table>
   </FormTemplate>
</EditFormSettings>

And the following code-behind:

protected void rgCommunications_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
   if (e.CommandName == RadGrid.InitInsertCommandName)
   {
      e.Canceled = true;

      //Prepare an IDictionary with the predefined values
      ListDictionary newValues = new ListDictionary();
      newValues["Titles"] = "Mrs.";
      //Insert the item and rebind 
      e.Item.OwnerTableView.InsertItem(newValues);
      GridEditCommandColumn editColumn = (GridEditCommandColumn)rgCommunications.MasterTableView.GetColumn("EditCommandColumn");
      editColumn.Visible = false;
   }
}

This works fine, the drop down is populated.  Now, what I can not get right is the selected value when in edit mode.  I know there is a SelectedValue property, but I am not getting it right, or is there somethinf else that I need to set?  When you go in edit mode, I want the title to be selected from Title.TitleID.

Please help..

Tags
Grid
Asked by
Brendan Vogt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Brendan Vogt
Top achievements
Rank 1
Share this question
or