|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem updating with TableAdapter in Detailsview.detailsview: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'IssueUpdateQuery' that has parameters: Portfolio_ID, Issue, DateCreated, POC, DueDate, Description, Priority, Status, Action, DateClosed, Date_Assigned, Overall_Issue_Rating, original_Issue_ID. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. I have tried rebuilding the tableAdapter multiple times. My stored procedure actually takes one more parameter which is Issue_ID, but it is not listed in this signature. Here is the stored procedure: CREATE PROCEDURE dbo.IssueUpdateQuery ( @Portfolio_ID int, @Issue varchar(50), @DateCreated datetime, @POC varchar(50), @DueDate smalldatetime, @Description varchar(50), @Priority varchar(50), @Status varchar(50), @Action varchar(50), @DateClosed datetime, @Date_Assigned smalldatetime, @Overall_Issue_Rating varchar(10), @Original_Issue_ID int, @Issue_ID int ) AS SET NOCOUNT OFF; UPDATE [PfM_Issues] SET [Portfolio_ID] = @Portfolio_ID, [Issue] = @Issue, [DateCreated] = @DateCreated, [POC] = @POC, [DueDate] = @DueDate, [Description] = @Description, [Priority] = @Priority, [Status] = @Status, [Action] = @Action, [DateClosed] = @DateClosed, [Date_Assigned] = @Date_Assigned, [Overall_Issue_Rating] = @Overall_Issue_Rating WHERE (([Issue_ID] = @Original_Issue_ID)); SELECT Issue_ID, Portfolio_ID, Issue, DateCreated, POC, DueDate, Description, Priority, Status, Action, DateClosed, Date_Assigned, Overall_Issue_Rating FROM PfM_Issues WHERE (Issue_ID = @Issue_ID) GO Code that builds the detailsview: <form id="form1" runat="server"> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False" CellPadding="4" DataKeyNames="Issue_ID" DataSourceID="ObjectDataSource1" Font-Size="Small" ForeColor="#333333" GridLines="None" Height="50px" Width="100%" Font-Names="Arial"> <FooterStyle BackColor="#DAD4B9" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> <EditRowStyle BackColor="#999999" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <PagerStyle BackColor="#FFFBE7" ForeColor="#48453D" HorizontalAlign="Center" /> <Fields> <asp:BoundField DataField="Issue_ID" HeaderText="Issue_ID" SortExpression="Issue_Id" Visible="False"/> <asp:BoundField DataField="Portfolio_ID" HeaderText="Portfolio_ID" SortExpression="Portfolio_ID" Visible="False"/> <asp:BoundField DataField="Issue" HeaderText="Issue" SortExpression="Issue" /> <icor:CalendarField DataField="DateCreated" HeaderText="Date Created" DataFormatString="dd MMM, yyyy" ReadOnly="False" /> <asp:BoundField DataField="POC" HeaderText="POC" SortExpression="POC" /> <icor:CalendarField DataField="DueDate" HeaderText="Due Date" DataFormatString="dd MMM, yyyy" ReadOnly="False" /> <asp:TemplateField HeaderText="Issue Description & Dependencies" SortExpression="Description"> <EditItemTemplate> <asp:TextBox ID="txtDescription" rows="6" runat="server" TextMode="multiLine" Text='<%#Bind("Description") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:TextBox ReadOnly="true" ID="txtDescription" rows="6" runat="server" TextMode="multiLine" Text='<%#Bind("Description") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField SortExpression="Priority" HeaderText="Priority" > <EditItemTemplate> <asp:DropDownList DataTextField="Priority" DataValueField="Priority" ID="drpPriority" Runat="server" SelectedValue='<%# Bind("Priority") %>'> <asp:ListItem Value="High" Text="High"></asp:ListItem> <asp:ListItem Value="Moderate" Text="Moderate"></asp:ListItem> <asp:ListItem Value="Low" Text="Low"></asp:ListItem> </asp:DropDownList> </EditItemTemplate> <ItemTemplate > <asp:Label Runat="server" Text='<%# Bind("Priority") %>' ID="lblPriority"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField SortExpression="Status" HeaderText="Status" > <EditItemTemplate> <asp:DropDownList DataTextField="Status" DataValueField="Status" ID="drpStatus" Runat="server" SelectedValue='<%# Bind("Status") %>'> <asp:ListItem Value="Red" Text="Red"></asp:ListItem> <asp:ListItem Value="Yellow" Text="Yellow"></asp:ListItem> <asp:ListItem Value="Green" Text="Green"></asp:ListItem> </asp:DropDownList> </EditItemTemplate> <ItemTemplate > <asp:Label Runat="server" Text='<%# Bind("Status") %>' ID="lblStatus"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField SortExpression="Action" HeaderText="Action" > <EditItemTemplate> <asp:DropDownList DataTextField="Action" DataValueField="Action" ID="drpAction" Runat="server" SelectedValue='<%# Bind("Action") %>'> <asp:ListItem Value="Open" Text="Open"></asp:ListItem> <asp:ListItem Value="Closed" Text="Closed"></asp:ListItem> </asp:DropDownList> </EditItemTemplate> <ItemTemplate > <asp:Label Runat="server" Text='<%# Bind("Action") %>' ID="lblAction"></asp:Label> </ItemTemplate> </asp:TemplateField> <icor:CalendarField DataField="DateClosed" HeaderText="Date Closed" DataFormatString="dd MMM, yyyy" ReadOnly="False" /> <icor:CalendarField DataField="Date_Assigned" HeaderText="Date Assigned" DataFormatString="dd MMM, yyyy" ReadOnly="False" /> <asp:TemplateField SortExpression="Overall_Issue_Rating" HeaderText="Overall Issue Rating" > <EditItemTemplate> <asp:DropDownList DataTextField="Overall_Issue_Rating" DataValueField="Overall_Issue_Rating" ID="drpOverall_Issue_Rating" Runat="server" SelectedValue='<%# Bind("Overall_Issue_Rating") %>'> <asp:ListItem Value="Red" Text="Red"></asp:ListItem> <asp:ListItem Value="Yellow" Text="Yellow"></asp:ListItem> <asp:ListItem Value="Green" Text="Green"></asp:ListItem> </asp:DropDownList> </EditItemTemplate> <ItemTemplate > <asp:Label Runat="server" Text='<%# Bind("Overall_Issue_Rating") %>' ID="lblOverallIssueRating"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ButtonType="Button" ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" /> </Fields> <FieldHeaderStyle BackColor="#DAD4B9" Font-Bold="True" /> <HeaderStyle BackColor="#DAD4B9" Font-Bold="True" ForeColor="#48453D" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:DetailsView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="IssueDeleteQuery" InsertMethod="IssueInsertQuery" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataByPortfolioId" TypeName="DataSet1TableAdapters.PfM_IssuesTableAdapter" UpdateMethod="IssueUpdateQuery"> <DeleteParameters> <asp:Parameter Name="Original_Issue_ID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:QueryStringParameter Name="Portfolio_ID" QueryStringField="psItemId" Type="Int32" /> <asp:Parameter Name="Issue" Type="String" /> <asp:Parameter Name="DateCreated" Type="DateTime" /> <asp:Parameter Name="POC" Type="String" /> <asp:Parameter Name="DueDate" Type="DateTime" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="String" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="Action" Type="String" /> <asp:Parameter Name="DateClosed" Type="DateTime" /> <asp:Parameter Name="Date_Assigned" Type="DateTime" /> <asp:Parameter Name="Overall_Issue_Rating" Type="String" /> <asp:Parameter Name="Original_Issue_ID" Type="Int32" /> <asp:Parameter Name="Issue_ID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:QueryStringParameter Name="Portfolio_ID" QueryStringField="psItemId" Type="Int32" /> <asp:Parameter Name="Issue" Type="String" /> <asp:Parameter Name="DateCreated" Type="DateTime" /> <asp:Parameter Name="POC" Type="String" /> <asp:Parameter Name="DueDate" Type="DateTime" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="String" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="Action" Type="String" /> <asp:Parameter Name="DateClosed" Type="DateTime" /> <asp:Parameter Name="Date_Assigned" Type="DateTime" /> <asp:Parameter Name="Overall_Issue_Rating" Type="String" /> </InsertParameters> <SelectParameters> <asp:QueryStringParameter Name="portfolio_id" QueryStringField="psItemId" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> XML schema from xsd: <UpdateCommand> <DbCommand CommandType="StoredProcedure" ModifiedByUser="False"> <CommandText>dbo.IssueUpdateQuery</CommandText> <Parameters> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Portfolio_ID" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="Portfolio_ID" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Issue" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="Issue" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@DateCreated" Precision="23" ProviderType="DateTime" Scale="3" Size="8" SourceColumn="DateCreated" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@POC" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="POC" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@DueDate" Precision="16" ProviderType="SmallDateTime" Scale="0" Size="4" SourceColumn="DueDate" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Description" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="Description" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Priority" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="Priority" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Status" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="Status" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Action" Precision="0" ProviderType="VarChar" Scale="0" Size="50" SourceColumn="Action" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@DateClosed" Precision="23" ProviderType="DateTime" Scale="3" Size="8" SourceColumn="DateClosed" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Date_Assigned" Precision="16" ProviderType="SmallDateTime" Scale="0" Size="4" SourceColumn="Date_Assigned" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Overall_Issue_Rating" Precision="0" ProviderType="VarChar" Scale="0" Size="10" SourceColumn="Overall_Issue_Rating" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Issue_ID" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="Issue_ID" SourceColumnNullMapping="False" SourceVersion="Original"> </Parameter> <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Issue_ID" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="Issue_ID" SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter> </Parameters> </DbCommand> </UpdateCommand> </DbSource> </MainSource> <Mappings> <Mapping SourceColumn="Issue_ID" DataSetColumn="Issue_ID" /> <Mapping SourceColumn="Portfolio_ID" DataSetColumn="Portfolio_ID" /> <Mapping SourceColumn="Issue" DataSetColumn="Issue" /> <Mapping SourceColumn="DateCreated" DataSetColumn="DateCreated" /> <Mapping SourceColumn="POC" DataSetColumn="POC" /> <Mapping SourceColumn="DueDate" DataSetColumn="DueDate" /> <Mapping SourceColumn="Description" DataSetColumn="Description" /> <Mapping SourceColumn="Priority" DataSetColumn="Priority" /> <Mapping SourceColumn="Status" DataSetColumn="Status" /> <Mapping SourceColumn="Action" DataSetColumn="Action" /> <Mapping SourceColumn="DateClosed" DataSetColumn="DateClosed" /> <Mapping SourceColumn="Date_Assigned" DataSetColumn="Date_Assigned" /> <Mapping SourceColumn="Overall_Issue_Rating" DataSetColumn="Overall_Issue_Rating" /> </Mappings> Any help would be greatly appreciated. Thanks in Advance, Don Hurley Hi Don,
Thank you for your post. Based on my understanding, the problem is: 1) You added a strong typed DataSet and generated stored procedures for the TableAdapter to update, insert, etc. 2) You added an ObjectDataSource object to connect to the TableAdapter; 3) You bind a DetailsView to the ObjectDataSource object and some fields are hidden; 4) When updating the record using the DetailsView, ObjectDataSource raises exception about incorrect method parameters. If I've misunderstood anything, please feel free to post here. I reproduced the problem you described and found it's a known limitation of current version of ObjectDataSource and DetailsView. If you make all fields visible and updatable, the updating should work correctly. The problem is related to hidden or readonly fields might not be included in the update method. You may use following steps as a workaround: 1) When a field is set to hidden in DetailsView, it's not rendered to client and will not be included in the update method parameters collection. To workaround it, add the field name to DetailsView.DataKeyNames, for example: DataKeyNames="Issue_ID,Portfolio_ID" This will make sure their values get passed along to the update method of ObjectDataSource. 2) By default, ObjectDataSource.OldValuesParameterFormatString is set to "original_{0}" and will pass along the original PK fields' values. Since we added other non-PK fields to DetailsView.DataKeyNames in previous step, we need to change this property to "{0}" to prevent unnecessary original field names getting generated; we will re-add the field "Original_Issue_ID" which is required by the Stored Procedure: protected void ObjectDataSource1_Updating(object sender, ObjectDataSourceMethodEventArgs e) { e.InputParameters["Original_Issue_ID"] = e.InputParameters["Issue_ID"]; } 3) Since the Stored Procedure used to delete record only has one parameter "Original_Issue_ID", we need to fix it in the Deleting event of ObjectDataSource: protected void ObjectDataSource1_Deleting(object sender, ObjectDataSourceMethodEventArgs e) { object Issue_ID = e.InputParameters["Issue_ID"]; e.InputParameters.Clear(); e.InputParameters.Add("Original_Issue_ID", Issue_ID); } Hope this helps. Please note that the above code may need some change to work in your project. Anyway, please update me whether or not it works. Regards, Walter Wang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hi Walter,
I haven't had a chance to try this out yet, but I have to mention that I don't put portfolio_id in the datakeynames since I pass it by querystring. the almost exact same code works on other pages. Insert and Delete work on this page, just not update. Thanks, Don Show quoteHide quote "Walter Wang [MSFT]" wrote: > Hi Don, > > Thank you for your post. > > Based on my understanding, the problem is: > 1) You added a strong typed DataSet and generated stored procedures for the > TableAdapter to update, insert, etc. > 2) You added an ObjectDataSource object to connect to the TableAdapter; > 3) You bind a DetailsView to the ObjectDataSource object and some fields > are hidden; > 4) When updating the record using the DetailsView, ObjectDataSource raises > exception about incorrect method parameters. > If I've misunderstood anything, please feel free to post here. > > I reproduced the problem you described and found it's a known limitation of > current version of ObjectDataSource and DetailsView. If you make all fields > visible and updatable, the updating should work correctly. The problem is > related to hidden or readonly fields might not be included in the update > method. > > You may use following steps as a workaround: > > 1) When a field is set to hidden in DetailsView, it's not rendered to > client and will not be included in the update method parameters collection. > To workaround it, add the field name to DetailsView.DataKeyNames, for > example: > > DataKeyNames="Issue_ID,Portfolio_ID" > > This will make sure their values get passed along to the update method > of ObjectDataSource. > > 2) By default, ObjectDataSource.OldValuesParameterFormatString is set to > "original_{0}" and will pass along the original PK fields' values. Since we > added other non-PK fields to DetailsView.DataKeyNames in previous step, we > need to change this property to "{0}" to prevent unnecessary original field > names getting generated; we will re-add the field "Original_Issue_ID" which > is required by the Stored Procedure: > > protected void ObjectDataSource1_Updating(object sender, > ObjectDataSourceMethodEventArgs e) > { > e.InputParameters["Original_Issue_ID"] = > e.InputParameters["Issue_ID"]; > } > > 3) Since the Stored Procedure used to delete record only has one parameter > "Original_Issue_ID", we need to fix it in the Deleting event of > ObjectDataSource: > > protected void ObjectDataSource1_Deleting(object sender, > ObjectDataSourceMethodEventArgs e) > { > object Issue_ID = e.InputParameters["Issue_ID"]; > e.InputParameters.Clear(); > e.InputParameters.Add("Original_Issue_ID", Issue_ID); > } > > Hope this helps. Please note that the above code may need some change to > work in your project. Anyway, please update me whether or not it works. > > > Regards, > Walter Wang > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > Hi Don,
Thank you for you quick update. I think I might have misunderstood something in last post. Anyway, the exception you're experiencing is due to incorrect parameters between the DetailsView and ObjectDataSource. From the exception, only the last parameter "Issue_ID" is missing. So I think the simplest fix would be add it in the ObjectDataSource's Updating event: e.InputParameters.Add("Issue_ID", e.InputParameters["Original_Issue_ID"]); Again, please feel free to post here if I've misunderstood anything or the suggestion still doesn't work. Regards, Walter Wang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. That worked, I just find it odd that it worked in all of my other pages, just
not that one. Thanks, Don Hurley Show quoteHide quote "Walter Wang [MSFT]" wrote: > Hi Don, > > Thank you for you quick update. > > I think I might have misunderstood something in last post. Anyway, the > exception you're experiencing is due to incorrect parameters between the > DetailsView and ObjectDataSource. From the exception, only the last > parameter "Issue_ID" is missing. So I think the simplest fix would be add > it in the ObjectDataSource's Updating event: > > e.InputParameters.Add("Issue_ID", > e.InputParameters["Original_Issue_ID"]); > > Again, please feel free to post here if I've misunderstood anything or the > suggestion still doesn't work. > > > Regards, > Walter Wang > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > Hi Don,
Appreciate your update and response. I am glad to hear that the problem has been fixed. If you have any other questions or concerns, please do not hesitate to contact us. It is always our pleasure to be of assistance. Have a nice day! Regards, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Gridview right border on a per-column basis
how to get the text in JS of a cell created on server? Validators - error message not showing when JS disabled & only server side validation occurs aspx and ascx can get forecolor but not background color in Javascript Web User Controls(ascx) 1.1 VS 2.0 ASP.NET 2.0 Intrinsic Treeview control errors on a specific machine making a dropdownlist visible when clicking in a textbox of a detailsview? Gridview Header Template sorting Changing default behaviour of ASP.NET2 Menu control |
|||||||||||||||||||||||