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

RadGrid, ObjectDataSource and Parameters

1 Answer 274 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thiago
Top achievements
Rank 1
Thiago asked on 20 Jun 2010, 03:11 AM
Hey there,

I've got a RadGrid bound to an objectDataSource but I've been running into an odd situation, on my grid I got the following declared:
<telerik:GridDropDownColumn DataField="Continent.Id" HeaderText="Continente" DataSourceID="odsContinent" ListTextField="Name" ListValueField="Id" UniqueName="Continent" SortExpression="Continent" />

The problem is, regardless of the params I set on my objectDataSource I am not able to switch the param name from Continent.Id to something I could name a parameter on C# Code, so I always end up with the following error when trying to update an item:

"Sys.WebForms.PageRequestManagerServerErrorException: ObjectDataSource 'odsCountry' could not find a non-generic method 'GridUpdate' that has parameters: Alias, Fullname, Capital, Continent.Id, ThreeDigitCountryCode, ThreeLetterCountryCode, TwoLetterCountryCode, Id."


<asp:ObjectDataSource ID="odsCountry" runat="server" 
            TypeName="Highland.Models.Country" 
            EnablePaging="true"             
            SelectMethod="SlicedFindAll"  
            SelectCountMethod="Count" 
            OldValuesParameterFormatString="{0}" 
            InsertMethod="GridInsert" DeleteMethod="GridDelete" UpdateMethod="GridUpdate"             
            StartRowIndexParameterName="firstResult" 
            MaximumRowsParameterName="maxResults" > 
            <DeleteParameters> 
                <asp:Parameter Name="Id" Type="Int32" /> 
            </DeleteParameters> 
            <UpdateParameters> 
                <asp:Parameter Name="Id" Type="Int32" /> 
                <asp:Parameter Name="Alias" Type="String" /> 
                <asp:Parameter Name="Fullname" Type="String" /> 
                <asp:Parameter Name="Capital" Type="String" /> 
                <asp:Parameter Name="Continent" Type="String" /> 
                <asp:Parameter Name="ThreeDigitCountryCode" Type="Int32" /> 
                <asp:Parameter Name="ThreeLetterCountryCode" Type="String" /> 
                <asp:Parameter Name="TwoLetterCountryCode" Type="String" /> 
            </UpdateParameters> 
            <InsertParameters> 
                <asp:Parameter Name="Id" Type="Int32" /> 
            </InsertParameters> 
        </asp:ObjectDataSource>  

Thanks for your time :)

-Thi


1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 22 Jun 2010, 12:00 PM
Hi Thiago,

There are several way to correct the error you are getting:
     - You should use ObjectDataSource's Updating event to modify the constructed InputParameters list (passed through the event's argument object).
    - Consider handling the CUD operations manually, instead using DataSourceControl
    - Consider setting the column as ReadOnly thus its values will not be added to InputParameters collection

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Thiago
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or