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

Error on insert

8 Answers 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 19 Mar 2008, 06:38 PM
I'm using a Prometheus RadGrid that's bound to an IList, and I'm having some trouble with inserts. When I click the Add button, I get an exception:

DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'PhoneType'.

The error occurs as soon as I press the Add button, before the table shows any insertion controls. As far as I know, I'm not missing any relevant events, but I can't seem to figure out what I'm doing wrong. My table is declared like this:

    <telerik:RadGrid runat="server" ID="phoneGrid" AutoGenerateColumns="false" > 
        <MasterTableView CommandItemDisplay="Bottom"
            <Columns> 
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" /> 
                <telerik:GridBoundColumn DataField="ContactPhoneid" Visible="false" ReadOnly="true" /> 
                <telerik:GridDropDownColumn DataField="PhoneType.PhoneTypeName" HeaderText="Type" ListTextField="PhoneTypeName" ListValueField="PhoneTypeid" DataSourceID="phoneTypeSource" /> 
                <telerik:GridBoundColumn DataField="Phone.PhoneNumber" HeaderText="Phone Number" MaxLength="50" /> 
                <telerik:GridBoundColumn DataField="Phone.PhoneExtension" HeaderText="Extension" MaxLength="10" /> 
                <telerik:GridBoundColumn DataField="Phone.PhoneDesc" HeaderText="Description" MaxLength="50" /> 
                <telerik:GridButtonColumn ButtonType="LinkButton" Text="Delete" CommandName="Delete" ConfirmText="Are you sure you want to delete this entry?" /> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 

I'm catching NeedDataSource, ItemCommand, and ItemInserted. Am I missing something, or is there a bug with object binding and subobjects?

8 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 20 Mar 2008, 04:31 PM
Hello Ralph,

Unfortunately, this scenario is not supported for GridDropDownColumn. The workaround is to use GridTemplateColumn with a DropDownList in EditItemTemplate.

Please, accept our apologies for the inconvenience caused.


Kind regards,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dstj
Top achievements
Rank 1
answered on 12 May 2008, 06:53 PM
Hi Ves,

I too am facing the same problem as Ralph.You mention that this scenario is not supported for GridDropDownColumn. Is is not supported "for the moment" and will be in future releases or is it not supported period?

Thanks for the information,

Dominic.
0
Rosen
Telerik team
answered on 15 May 2008, 08:36 AM
Hi Dominic,

I'm happy to inform you that our developers have addressed this request. Therefore the fix will be available in the next service pack which is expected to be released by the end of the week.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dwayne
Top achievements
Rank 1
answered on 28 Jul 2009, 11:55 PM
I am still having this issue I noticed that on my insertion when my result set comes back as null this happens if there is a fix out there where can i find it. Thanks
0
Dwayne
Top achievements
Rank 1
answered on 29 Jul 2009, 12:43 AM
I don't know if it matters but i am using a grid as a user control and the edit form is also a user control and when i have a empty dataset the insert blows up  and this is the same with all insert that are created in this fashion
0
BaiH
Top achievements
Rank 1
answered on 31 Jul 2009, 01:38 PM
Let me guess, you are using a collection of custom object, maybe with nested sub objects? In such case you should do something like this:

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
   if (e.CommandName == RadGrid.InitInsertCommandName) 
   { 
       e.Canceled = true
       e.Item.OwnerTableView.InsertItem(new MyCustomEntity()); 
   } 

This will pass a instance of your custom object to grid's insert form ensuring that all fields are there.

--BH


0
FreshOne
Top achievements
Rank 1
answered on 08 Mar 2010, 10:01 AM
hi BaiH,
ur solution works perfectly excepts when the object includes a foreign key, i get this error:
Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value

here is my code
        If e.CommandName = RadGrid.InitInsertCommandName Then 
            e.Canceled = True 
            e.Item.OwnerTableView.InsertItem(New City())  
        End If 

object city includes countryID as a foreign key

any ideas?
thnx in advance
0
Ramya
Top achievements
Rank 1
answered on 14 Nov 2013, 07:33 PM
BH - you saved my day. I am using nested objects and it worked. Thank you!
Tags
Grid
Asked by
Neil
Top achievements
Rank 1
Answers by
Ves
Telerik team
dstj
Top achievements
Rank 1
Rosen
Telerik team
Dwayne
Top achievements
Rank 1
BaiH
Top achievements
Rank 1
FreshOne
Top achievements
Rank 1
Ramya
Top achievements
Rank 1
Share this question
or