none
Could Not Find A Non-Generic Method 'Update' That Has Parameters

    Pertanyaan

  • Please move this question if this is the wrong forum.

    I have an application that is using a asp:listview. it is tied to an  It works except for the UPDATE statement. The error I am receiving is: 

    ObjectDataSource 'Scope_Mapping_ObjectDataSource' could not find a non-generic method 'Update' that has parameters: original_Scope_ID, original_Import_Source_ID, original_Import_Program_Name, original_Import_Scope_Name, Scope_Name, Import_Source_Acronym, Import_Program_Name, Import_Scope_Name.

    The issue seems to be the "Scope_Name" and "Import_Source_Acronym" parameters. My ObjectDataSource uses the generic UPDATE statement. This statement uses "Scope_ID" and Import_Source_ID" and not "Scope_Name" and "Import_Source_Acronym. This is how I have my ObjectDataSource configured:

    <asp:ObjectDataSource ID="Scope_Mapping_ObjectDataSource" runat="server" 
            DeleteMethod="Delete" 
            InsertMethod="Insert" 
            OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetDataByPMMProgramID" 
            TypeName="BI_Datamart_PMMTableAdapters.Scope_MappingTableAdapter" 
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="Original_Scope_ID" Type="Int32" />
                <asp:Parameter Name="Original_Import_Source_ID" Type="Int32" />
                <asp:Parameter Name="Original_Import_Program_Name" Type="String" />
                <asp:Parameter Name="Original_Import_Scope_Name" Type="String" />
            </DeleteParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="Program_DDL" Name="PMM_Program_ID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="Scope_ID" Type="Int32" />
                <asp:Parameter Name="Import_Source_ID" Type="Int32" />
                <asp:Parameter Name="Import_Program_Name" Type="String" />
                <asp:Parameter Name="Import_Scope_Name" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Scope_ID" Type="Int32" />
    			<asp:Parameter Name="Import_Source_ID" Type="Int32" />
    			<asp:Parameter Name="Import_Program_Name" Type="String" />
                <asp:Parameter Name="Import_Scope_Name" Type="String" />
                <asp:Parameter Name="Original_Scope_ID" Type="Int32" />
                <asp:Parameter Name="Original_Import_Source_ID" Type="Int32" />
                <asp:Parameter Name="Original_Import_Program_Name" Type="String" />
                <asp:Parameter Name="Original_Import_Scope_Name" Type="String" />
            </UpdateParameters>
        </asp:ObjectDataSource>


    Here is my listview:

    <asp:ListView ID="MapNames_ListView" runat="server" 
            DataKeyNames="Scope_ID,Import_Program_Name,Import_Scope_Name,Import_Source_ID" 
            DataSourceID="Scope_Mapping_ObjectDataSource" 
            InsertItemPosition="FirstItem" 
            oniteminserting="MapNames_ListView_ItemInserting"
            OnItemInserted="MapNames_ListView_ItemInserted" 
            OnItemDeleting="MapNames_ListView_ItemDeleting"
            OnItemDeleted="MapNames_ListView_ItemDeleted" 
            onitemdatabound="MapNames_ListView_ItemDataBound" 
            ondatabound="MapNames_ListView_DataBound"
            OnItemUpdating="MapNames_ListView_ItemUpdating"
            OnItemUpdated="MapNames_ListView_ItemUpdated" >
            <ItemTemplate>
                <tr style="background-color:#DCDCDC;color: #000000;">
                    
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" 
                            OnClientClick="if(!confirm('Are you sure you want to delete this row?'))return false;" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    </td>
                    <td>
                        <asp:Label ID="Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Scope_Name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Source_Acronym_Label" runat="server" 
                            Text='<%# Eval("Import_Source_Acronym") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Program_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Program_Name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Scope_Name") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr style="background-color:#FFF8DC;">
                   <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" 
                            OnClientClick="if(!confirm('Are you sure you want to delete this row?'))return false;" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    </td>
                    <td>
                        <asp:Label ID="Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Scope_Name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Source_Acronym_Label" runat="server" 
                            Text='<%# Eval("Import_Source_Acronym") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Program_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Program_Name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Scope_Name") %>' />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <EmptyDataTemplate>
                <table id="Table1" runat="server" 
                    style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                    <tr>
                        <td>
                            No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">
                    <td>
                        <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                            Text="Insert" ValidationGroup="Insert_Map" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                            Text="Clear" />
                    </td>
                    <td>
                        <asp:DropDownList ID="Scope_InsertDDL" runat="server"
                            DataSourceID="Scope_ObjectDataSource"
                            DataTextField="Scope_Name" DataValueField="Scope_ID"></asp:DropDownList>
                        <asp:RequiredFieldValidator ID="Scope_Insert_Validator" runat="server" 
                            ErrorMessage="Required" ValidationGroup="Insert_Map" 
                            ControlToValidate="Scope_InsertDDL" Display="Dynamic"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        <asp:DropDownList ID="Import_Source_InsertDDL" runat="server"
                            DataSourceID="Import_Source_ObjectDataSource" AppendDataBoundItems="true"
                            DataTextField="Import_Source_Acronym" DataValueField="Import_Source_ID">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="Import_Source_Insert_Validator" runat="server" 
                            ErrorMessage="Required" ValidationGroup="Insert_Map" 
                            ControlToValidate="Import_Source_InsertDDL" Display="Dynamic"></asp:RequiredFieldValidator>
                    </td> 
                    <td>
                        <asp:TextBox ID="Import_Program_Name_TextBox" runat="server" width="400"
                            Text='<%# Bind("Import_Program_Name") %>' MaxLength="200" />
                        <asp:RequiredFieldValidator ID="Import_Program_Name_Insert_Validator" runat="server" 
                            ErrorMessage="Required" ValidationGroup="Insert_Map" 
                            ControlToValidate="Import_Program_Name_TextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                    </td>   
                    <td>
                        <asp:TextBox ID="Import_Scope_Name_TextBox" runat="server"  width="800"
                            Text='<%# Bind("Import_Scope_Name") %>' MaxLength="500" />
                        <asp:RequiredFieldValidator ID="Import_Scope_Name_Insert_Validator" runat="server" 
                            ErrorMessage="Required" ValidationGroup="Insert_Map" 
                            ControlToValidate="Import_Scope_Name_TextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                    </td>            
                </tr>
            </InsertItemTemplate>
            <LayoutTemplate>
                <table id="Table2" runat="server">
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <table ID="itemPlaceholderContainer" runat="server" border="1" 
                                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                                <tr id="Tr2" runat="server" style="background-color:#DCDCDC;color: #000000;">
                                    <th width="150px" id="Th1" runat="server"></th>
                                    <th id="Th2" runat="server">Scope Name</th>
                                    <th id="Th3" runat="server">Import Source</th>
                                    <th id="Th4" runat="server">Import Program Name</th>
                                    <th id="Th5" runat="server">Import Scope Name</th>
                                </tr>
                                <tr ID="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr id="Tr3" runat="server">
                        <td id="Td2" runat="server" 
                            style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                            <asp:DataPager ID="DataPager1" runat="server" PageSize="48">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
                    <td>
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                    </td>
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
                    </td>
                    <td>
                        <asp:Label ID="Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Scope_Name_Acronym") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Source_Acronym_Label" runat="server" 
                            Text='<%# Eval("Import_Source_Acronym") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Program_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Program_Name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Import_Scope_Name_Label" runat="server" 
                            Text='<%# Eval("Import_Scope_Name") %>' />
                    </td>
                </tr>
            </SelectedItemTemplate>
            <EditItemTemplate>
                <tr style="color: #000000;">
                    <td>
                        <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                            Text="Update" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                            Text="Cancel" />
                    </td>
                     <td>
                        <asp:TextBox ID="Scope_Name_TextBox" runat="server" Text='<%# Bind("Scope_Name") %>' width="25px" ReadOnly="true" BackColor="LightGray"/>
                    </td>
                    <td>
                        <asp:TextBox ID="Import_Source_Acronym_TextBox" runat="server" Text='<%# Bind("Import_Source_Acronym") %>' width="25px" ReadOnly="true" BackColor="LightGray"/>
                    </td>
                    <td>
                        <asp:TextBox ID="Import_Program_Name_TextBox" runat="server" Text='<%# Bind("Import_Program_Name") %>' width="400px" MaxLength="200" />
                    </td>
                    <td>
                        <asp:TextBox ID="Import_Scope_Name_TextBox" runat="server" Text='<%# Bind("Import_Scope_Name") %>' width="800px" MaxLength="500" />
                    </td>
                </tr>
            </EditItemTemplate>
        </asp:ListView>  

    Here is the Update in the xsd behind the TableAdapter:

     <UpdateCommand>
                      <DbCommand CommandType="Text" ModifiedByUser="false">
                        <CommandText>UPDATE [Scope_Mapping] SET [Scope_ID] = @Scope_ID, [Import_Source_ID] = @Import_Source_ID, [Import_Program_Name] = @Import_Program_Name, [Import_Scope_Name] = @Import_Scope_Name WHERE (([Scope_ID] = @Original_Scope_ID) AND ([Import_Source_ID] = @Original_Import_Source_ID) AND ([Import_Program_Name] = @Original_Import_Program_Name) AND ([Import_Scope_Name] = @Original_Import_Scope_Name))</CommandText>
                        <Parameters>
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Scope_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Scope_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Import_Source_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Import_Source_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Import_Program_Name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Import_Program_Name" SourceColumnNullMapping="false" SourceVersion="Current" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Import_Scope_Name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Import_Scope_Name" SourceColumnNullMapping="false" SourceVersion="Current" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Scope_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Scope_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Import_Source_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Import_Source_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_Import_Program_Name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Import_Program_Name" SourceColumnNullMapping="false" SourceVersion="Original" />
                          <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_Import_Scope_Name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Import_Scope_Name" SourceColumnNullMapping="false" SourceVersion="Original" />
                        </Parameters>
                      </DbCommand>
                    </UpdateCommand>

    The table has the following columns:

    Scope_ID, 
    Import_Source_ID, 
    Import_Program_Name, 
    Import_Scope_Name, 
    Scope_Name,
    Import_Source_Acronym

    I don't understand why the Update is looking for the Scope_Name and Import_Source_Acronym when I'm telling it to use the Scope_ID and the Import_Source_ID.

    • Dipindahkan oleh CoolDadTxMVP 10 Juli 2018 14:36 ASP.NET related
    10 Juli 2018 13:37

Semua Balasan