RadGrid Insert Signature

8 posts, 0 answers
  1. David Kingston
    David Kingston avatar
    18 posts
    Member since:
    Jul 2006

    Posted 01 Oct 2008 Link to this post

    I have a RadGrid hooked up to an ObjectDataSource, and it's Ajax enabled.

    The update and delete functions work fine.  The insert function returns an error saying that it can't find a generic method that takes the parameters DivisionName, DivisionDescription, DivisionID.

    I don't get it, Division ID visible is set to false.  The signature for insert is just DivisionName and Divsion Description.  Why is it trying to add DivisionID to the equation?

    onitemcreated only does validation just like the example, and that works.

    The ASPX looks like this:

    <telerik:RadGrid ID="RadGrid1" runat="server"
    <MasterTableView DataSourceID="CmdbDivision"
    <HeaderStyle Width="20px"></HeaderStyle>

    <HeaderStyle Width="20px"></HeaderStyle>
            <telerik:GridBoundColumn DataField="DivisionID"
                HeaderText="DivisionID" SortExpression="DivisionID"
                UniqueName="DivisionID" DataType="System.Int32" Visible="False">
            <telerik:GridBoundColumn DataField="DivisionName" HeaderText="DivisionName"
                SortExpression="DivisionName" UniqueName="DivisionName">
            <telerik:GridBoundColumn DataField="DivisionDescription"
                HeaderText="DivisionDescription" SortExpression="DivisionDescription"
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete"
    <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
        <PagerStyle Mode="NextPrevAndNumeric" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    <FilterMenu EnableTheming="True">
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
    <asp:ObjectDataSource ID="CmdbDivision" runat="server"
                <asp:Parameter Name="DivisionID" Type="Object" />
                <asp:Parameter Name="DivisionID" Type="Int32" />
                <asp:Parameter Name="DivisionName" Type="String" />
                <asp:Parameter Name="DivisionDescription" Type="String" />
                <asp:Parameter Name="DivisionName" Type="String" />
                <asp:Parameter Name="DivisionDescription" Type="String" />

  2. David Kingston
    David Kingston avatar
    18 posts
    Member since:
    Jul 2006

    Posted 01 Oct 2008 Link to this post

    I had a sneaking suspicion that it is because DataKeyNames="DivisionID".  But that is not the case, and removing it makes the delete function not work anymore. 

    Anyone have suggestions, or know where the documentation for the generated method signature is at?  Or some property that I'm missing?

    I could have sworn that the insert was working before I got delete to work, but I can't find any combinations of settings that would make it work again.

  3. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 01 Oct 2008 Link to this post

    Hey David,

    Have you tried adding:

          <asp:Parameter Name="DivisionID" Type="Int32" />

    into the InsertParameters?  My best guess (without having the datasource and all that goodness) is that since DataKeyNames="DivisonID" then you will need to have that in every parameter group (insert, update, delete) as that's the key it is using...  let me know if that works. 
  4. David Kingston
    David Kingston avatar
    18 posts
    Member since:
    Jul 2006

    Posted 01 Oct 2008 Link to this post

    Nope.  I thought of that as well.  The method signature of my DAL for an insert is just DivisionName and DivisionDescription.  I also looked through the ObjectDataSource settings for insert, and can't find a method that includes the DivisionID as a signature.  My DAL was generated by SubSonic.  The table only contains an ID, Name, Description -- basic lookup table.

    I thought the update button just wired the necessary columns to the parameters in the ObjectDataSource.  Why is it adding paramters not defined by the ObjectDataSource?

    An interesting thing happens in the error message, though.  If you add DivisionID to the insert parameters above Name and Description, the exception lists the columns in a different order:
    InvalidOperationException: ObjectDataSource 'CmdbDivision' could not find a non-generic method 'Insert' that has parameters: DivisionID, DivisionName, DivisionDescription.

    Before the exception message had DivisionID at the end of the equation.  Like it looped through the parameters in the list and then added DivisionID at the end.

    I also messed around with visible, display, and read only for the ID column to no avail.

    I guess I can try to add a custom form template, or just wire up the insert event and write my own insert commands -- seems like I should be able to do this without any code though.  I mean who writes an insert statement that takes an ID that is autogenerated by the db?
  5. Scott Hansen
    Scott Hansen avatar
    2 posts
    Member since:
    Apr 2004

    Posted 30 Oct 2008 Link to this post

    Any resolution on this - having same problem.

  6. Nikolay Rusev
    Nikolay Rusev avatar
    2287 posts

    Posted 31 Oct 2008 Link to this post

    Hello ,

    On the links below you will find information about ObjectDataSource and how RadGrid is using any data source control:
    ObjectDataSource Class
    Automatic DataSource operations

    Regarding the issue which David has: GridBoundColumn with DataField DivisionID must be marked as ReadOnly=true instead. This will resolve the problem.

    Attached to this forum post you will find a sample project which illustrates another possible way to bind RadGrid via ObjectDataSource without need to specify any parameter for select/update/insert/delete.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. David Kingston
    David Kingston avatar
    18 posts
    Member since:
    Jul 2006

    Posted 31 Oct 2008 Link to this post

    I haven't tested this yet, but will try your suggestions later this afternoon.

    I also noticed that when you have SubSonic autogenerate the DAL for you that you need to refresh the files in Visual Studio to get new and updated signatures.  I don't know if this was a problem for me or not.

    In the mean time, I just made a Edit/Insert Template and caught the CommandItem from the save/insert button just like the online example for custom edit forms.  The custom form was a good idea, as I was able to add audit items that I wanted to include in the form down the road.

    I'd still like the auto edit/delete stuff to work.  I'll try your examples later this afternoon and post back here what I found.
  8. Nikolay Rusev
    Nikolay Rusev avatar
    2287 posts

    Posted 03 Nov 2008 Link to this post

    Hello David,

    If you don't need to change methods signature you can set ReadOnly=true for DivisionID column.
    Thus the value of this column won't be required.

    I hope the provided information so far is helpful.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top