Problem with ObjectDataSource + GridView
-
Hi, I am using a GridView that bound to an ObjectDataSource. This ObjectDataSource works against the business class containing the methods for updating and retrieving records. My problem is: After updating a record in the database the Gridview is not getting re-binding to reflect the changes. Instead it is throwing an error: "ObjectDataSource 'ObjProfile' could not find a non-generic method 'UpdateUserProfile' that has parameters: RoleID, FirstName, LastName, NickName, BirthDate, StreetAddress, State, Zip, Phone1, Email1, UserID." Any work arounds or help is appriciated. Below is the code that i used: Code written in .aspx page <asp:DropDownList ID="drdUserCategory" runat="server" CssClass="Label" Width="150px" AutoPostBack="true"> asp:DropDownList/ <asp:ObjectDataSource ID="ObjProfile" runat="server" TypeName="AEIBusiness.UsersProfile" UpdateMethod="UpdateUserProfile" SelectMethod="GetUserProfilesByRole" OldValuesParameterFormatString="{0}"> <SelectParameters> <asp:ControlParameter ControlID="drdUserCategory" Name="RoleID" PropertyName="selectedvalue" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="RoleID" Type="Int32" /> <asp:Parameter Name="UserID" Type="Int32" /> <asp:Parameter Name="FirstName" Type="string" /> <asp:Parameter Name="LastName" Type="string" /> <asp:Parameter Name="NickName" Type="string" /> <asp:Parameter Name="BirthDate" Type="string" /> <asp:Parameter Name="StreetAddress" Type="string" /> <asp:Parameter Name="State" Type="string" /> <asp:Parameter Name="Zip" Type="Int32" /> <asp:Parameter Name="Phone1" Type="string" /> <asp:Parameter Name="Email1" Type="string" /> </UpdateParameters> </asp:ObjectDataSource> <asp:GridView ID="grdUserProfile" runat="server" AutoGenerateColumns="False" BackColor="White" CssClass="Label" DataSourceID="ObjProfile" HorizontalAlign="Center" PageSize="10" AllowPaging="true" EmptyDataText="Record not found." EmptyDataRowStyle-HorizontalAlign="Center" CellPadding="2" GridLines="Vertical" BorderColor="InactiveBorder" BorderStyle="None" Bord
-
Hi, I am using a GridView that bound to an ObjectDataSource. This ObjectDataSource works against the business class containing the methods for updating and retrieving records. My problem is: After updating a record in the database the Gridview is not getting re-binding to reflect the changes. Instead it is throwing an error: "ObjectDataSource 'ObjProfile' could not find a non-generic method 'UpdateUserProfile' that has parameters: RoleID, FirstName, LastName, NickName, BirthDate, StreetAddress, State, Zip, Phone1, Email1, UserID." Any work arounds or help is appriciated. Below is the code that i used: Code written in .aspx page <asp:DropDownList ID="drdUserCategory" runat="server" CssClass="Label" Width="150px" AutoPostBack="true"> asp:DropDownList/ <asp:ObjectDataSource ID="ObjProfile" runat="server" TypeName="AEIBusiness.UsersProfile" UpdateMethod="UpdateUserProfile" SelectMethod="GetUserProfilesByRole" OldValuesParameterFormatString="{0}"> <SelectParameters> <asp:ControlParameter ControlID="drdUserCategory" Name="RoleID" PropertyName="selectedvalue" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="RoleID" Type="Int32" /> <asp:Parameter Name="UserID" Type="Int32" /> <asp:Parameter Name="FirstName" Type="string" /> <asp:Parameter Name="LastName" Type="string" /> <asp:Parameter Name="NickName" Type="string" /> <asp:Parameter Name="BirthDate" Type="string" /> <asp:Parameter Name="StreetAddress" Type="string" /> <asp:Parameter Name="State" Type="string" /> <asp:Parameter Name="Zip" Type="Int32" /> <asp:Parameter Name="Phone1" Type="string" /> <asp:Parameter Name="Email1" Type="string" /> </UpdateParameters> </asp:ObjectDataSource> <asp:GridView ID="grdUserProfile" runat="server" AutoGenerateColumns="False" BackColor="White" CssClass="Label" DataSourceID="ObjProfile" HorizontalAlign="Center" PageSize="10" AllowPaging="true" EmptyDataText="Record not found." EmptyDataRowStyle-HorizontalAlign="Center" CellPadding="2" GridLines="Vertical" BorderColor="InactiveBorder" BorderStyle="None" Bord
It is not helpful to post so much irrelevant code. Just the portions with the error would have sufficed. The error is telling you that your business object does not have a method with the signature you are calling (the parameters for UpdateUserProfile don't match - the function declaration has 11 parameters, your call has only 10). This post does not belong in the VISTA forum. Perhaps you meant to post in the SQL / ADO /ADO.net forum - you didn't post this in multiple forums, did you? That would be considered rude...