• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

Formview issues deleting or editing

Hey all-

Using VS2k5, c#, asp.net. Created a typed dataset tied to sprocs. Then, created an object datasource tied to teh dataset. Then, created a formview and tied it to the object data source. It automatically bound to the insert, update delete and select methods. Now, when I run the formview, I can view and insert data, but not do any other operations. When I click edit and change data and click save, it just comes back to the view screen like nothing happened. Delete is the same. I deleted a row by using code and stepping through it so I know at least teh delete proc is working.

What am I doing wrong?

Bill
0
KBSLPDev
Asked:
KBSLPDev
  • 3
  • 2
1 Solution
 
samtran0331Commented:
check the parameters that were created for the insert and delete methods...if it's not getting the correct parameters, the code won't know what to update/delete...
like if your stored procedure was:
Delete * From Customers Where CustomerID = @CustomerID

Check to make sure the generated code is pulling the correct form value for @CustomerID
0
 
KBSLPDevAuthor Commented:
I'm going to start by concentrating on teh delete method as it is the most simple. I've written this line in the page load

dsRulesTableAdapters.dtRulesTableAdapter ta = new dsRulesTableAdapters.dtRulesTableAdapter();
ta.Delete(2);

and it deleted record 2 fine. How can I tell what the formview is sending the object data source? It looks like from the table adapter down it's working fine.

Thoughts?          
0
 
samtran0331Commented:
so if hardcoding the value works, then it most likely is what I suspected with the parameters....can you post your code?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
KBSLPDevAuthor Commented:
Sure. Attached is teh section with the formview, ods and a few other controls. The methods of the object datasource are 'insert','update','delete', and 'getdata'.

    <asp:FormView ID="FormView1" runat="server" DataSourceID="odsRules" Height="481px" Width="672px"  AllowPaging="True" >
        <EditItemTemplate>
            product_rules_id:
            <asp:Label ID="product_rules_idLabel1" runat="server" Text='<%# Eval("product_rules_id") %>'>
            </asp:Label><br />
            supplier_im_id:
            <asp:TextBox ID="supplier_im_idTextBox" runat="server" Text='<%# Bind("supplier_im_id") %>'>
            </asp:TextBox><br />
            product_id:
            <asp:TextBox ID="product_idTextBox" runat="server" Text='<%# Bind("product_id") %>'>
            </asp:TextBox><br />
            company_id:
            <asp:TextBox ID="company_idTextBox" runat="server" Text='<%# Bind("company_id") %>'>
            </asp:TextBox><br />
            effective_date:
            <asp:TextBox ID="effective_dateTextBox" runat="server" Text='<%# Bind("effective_date") %>'>
            </asp:TextBox><br />
            base_cost:
            <asp:TextBox ID="base_costTextBox" runat="server" Text='<%# Bind("base_cost") %>'>
            </asp:TextBox><br />
            capability_support_cost:
            <asp:TextBox ID="capability_support_costTextBox" runat="server" Text='<%# Bind("capability_support_cost") %>'>
            </asp:TextBox><br />
            service_cost:
            <asp:TextBox ID="service_costTextBox" runat="server" Text='<%# Bind("service_cost") %>'>
            </asp:TextBox><br />
            cc_im:
            <asp:TextBox ID="cc_imTextBox" runat="server" Text='<%# Bind("cc_im") %>'>
            </asp:TextBox><br />
            cc_pct:
            <asp:TextBox ID="cc_pctTextBox" runat="server" Text='<%# Bind("cc_pct") %>'>
            </asp:TextBox><br />
            qh_im:
            <asp:TextBox ID="qh_imTextBox" runat="server" Text='<%# Bind("qh_im") %>'>
            </asp:TextBox><br />
            qh_margin:
            <asp:TextBox ID="qh_marginTextBox" runat="server" Text='<%# Bind("qh_margin") %>'>
            </asp:TextBox><br />
            qh_pct:
            <asp:TextBox ID="qh_pctTextBox" runat="server" Text='<%# Bind("qh_pct") %>'>
            </asp:TextBox><br />

            unit_type:
            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("unit_type") %>'>
            </asp:TextBox><br />

            active:
            <asp:CheckBox ID="activeCheckBox" runat="server" Checked='<%# Bind("active") %>' /><br />
            LastModBy:
            <asp:TextBox ID="LastModByTextBox" runat="server" Text='<%# Bind("LastModBy") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                Text="Update">
            </asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            supplier_im_id:
            <asp:TextBox ID="supplier_im_idTextBox" runat="server" Text='<%# Bind("supplier_im_id") %>'>
            </asp:TextBox><br />
            product_id:
            <asp:TextBox ID="product_idTextBox" runat="server" Text='<%# Bind("product_id") %>'>
            </asp:TextBox><br />
            company_id:
            <asp:TextBox ID="company_idTextBox" runat="server" Text='<%# Bind("company_id") %>'>
            </asp:TextBox><br />
            effective_date:
            <asp:TextBox ID="effective_dateTextBox" runat="server" Text='<%# Bind("effective_date") %>'>
            </asp:TextBox><br />
            base_cost:
            <asp:TextBox ID="base_costTextBox" runat="server" Text='<%# Bind("base_cost") %>'>
            </asp:TextBox><br />
            capability_support_cost:
            <asp:TextBox ID="capability_support_costTextBox" runat="server" Text='<%# Bind("capability_support_cost") %>'>
            </asp:TextBox><br />
            service_cost:
            <asp:TextBox ID="service_costTextBox" runat="server" Text='<%# Bind("service_cost") %>'>
            </asp:TextBox><br />
            cc_im:
            <asp:TextBox ID="cc_imTextBox" runat="server" Text='<%# Bind("cc_im") %>'>
            </asp:TextBox><br />
            cc_pct:
            <asp:TextBox ID="cc_pctTextBox" runat="server" Text='<%# Bind("cc_pct") %>'>
            </asp:TextBox><br />
            qh_im:
            <asp:TextBox ID="qh_imTextBox" runat="server" Text='<%# Bind("qh_im") %>'>
            </asp:TextBox><br />
            qh_margin:
            <asp:TextBox ID="qh_marginTextBox" runat="server" Text='<%# Bind("qh_margin") %>'>
            </asp:TextBox><br />
            qh_pct:
            <asp:TextBox ID="qh_pctTextBox" runat="server" Text='<%# Bind("qh_pct") %>'>
            </asp:TextBox><br />

            unit_type:
            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("unit_type") %>'>
            </asp:TextBox><br />

            active:
            <asp:CheckBox ID="activeCheckBox" runat="server" Checked='<%# Bind("active") %>' /><br />
            LastModBy:
            <asp:TextBox ID="LastModByTextBox" runat="server" Text='<%# Bind("LastModBy") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="Insert">
            </asp:LinkButton>
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            <table style="width: 455px">
                <tr>
                    <td style="width: 203px">
                    </td>
                    <td style="width: 459px">
                    </td>
                    <td style="width: 459px">
                    </td>
                </tr>
                <tr>
                    <td style="width: 203px">
                        <strong>
                        Supplier IM #</strong></td>
                    <td style="width: 459px">
                        <asp:Label ID="supplier_im_idLabel" runat="server" Text='<%# Bind("supplier_im_id") %>'></asp:Label></td>
                    <td style="width: 459px">
                    </td>
                </tr>
                <tr>
                    <td style="width: 203px">
                        <strong>
                        Product ID</strong></td>
                    <td style="width: 459px">
                        <asp:Label ID="product_idLabel" runat="server" Text='<%# Bind("product_id") %>'></asp:Label></td>
                    <td style="width: 459px">
                    </td>
                </tr>
                <tr>
                    <td style="width: 203px">
                        <strong>
                        Company ID</strong></td>
                    <td style="width: 459px">
                        <asp:Label ID="company_idLabel" runat="server" Text='<%# Bind("company_id") %>'></asp:Label></td>
                    <td style="width: 459px">
                    </td>
                </tr>
                <tr>
                    <td style="width: 203px">
                        <strong>
                        Effective Date</strong></td>
                    <td style="width: 459px">
                        <asp:Label ID="effective_dateLabel" runat="server" Text='<%# Bind("effective_date") %>'></asp:Label>
                    </td>
                    <td style="width: 459px">
                    </td>
                </tr>
            </table>
            <br />
            <table>
                <tr>
                    <td style="width: 100px; height: 21px">
                        <strong>
                        Base Cost</strong></td>
                    <td style="width: 100px; height: 21px">
                        <strong>
                        Capability Support Cost</strong></td>
                    <td style="width: 100px; height: 21px">
                        <strong>
                        Service Price</strong></td>
                    <td style="width: 100px; height: 21px">
                        <strong>QH IM #</strong></td>
                    <td style="width: 100px; height: 21px">
                        <strong>CC IM #</strong></td>
                </tr>
                <tr>
                    <td style="width: 100px">
                        <asp:Label ID="base_costLabel" runat="server" Text='<%# Bind("base_cost") %>'></asp:Label></td>
                    <td style="width: 100px">
                        <asp:Label ID="capability_support_costLabel" runat="server" Text='<%# Bind("capability_support_cost") %>'></asp:Label></td>
                    <td style="width: 100px">
                        <asp:Label ID="service_costLabel" runat="server" Text='<%# Bind("service_cost") %>'></asp:Label></td>
                    <td style="width: 100px">
                        <asp:Label ID="qh_imLabel" runat="server" Text='<%# Bind("qh_im") %>'></asp:Label></td>
                    <td style="width: 100px">
                        <asp:Label ID="cc_imLabel" runat="server" Text='<%# Bind("cc_im") %>'></asp:Label></td>
                </tr>
                <tr>
                    <td style="width: 100px">
                    </td>
                    <td style="width: 100px">
                    </td>
                    <td style="width: 100px">
                    </td>
                    <td style="width: 100px">
                    </td>
                    <td style="width: 100px">
                    </td>
                </tr>
                <tr>
                    <td colspan="5" style="text-align: center">
            <asp:Button ID="btnCalculate" runat="server" Text="Calculate Values" /></td>
                </tr>
            </table>
            <br />
            <asp:Panel ID="pnlCalc" runat="server" BackColor="Silver" BorderStyle="Ridge" Width="299px" Height="148px">
                <asp:Panel ID="pnlCalcDragPanel" runat="server" BackColor="DimGray" ForeColor="White">
                    <strong>Calculated Values</strong></asp:Panel>
                <table>
                    <tr>
                        <td style="width: 100px">
                            CC %</td>
                        <td style="width: 100px">
                            <asp:Label ID="cc_pctLabel" runat="server" Text='<%# Bind("cc_pct") %>'></asp:Label></td>
                    </tr>
                    <tr>
                        <td style="width: 100px">
                            Quality Holdback</td>
                        <td style="width: 100px">
                            <asp:Label ID="qh_marginLabel" runat="server" Text='<%# Bind("qh_margin") %>'></asp:Label></td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 21px;">
                            QH %</td>
                        <td style="width: 100px; height: 21px;">
                            <asp:Label ID="qh_pctLabel" runat="server" Text='<%# Bind("qh_pct") %>'></asp:Label></td>
                    </tr>
                    <tr>
                        <td colspan="2" style="height: 21px; text-align: center">
                <asp:Button ID="btnCalcOK" runat="server" Text="OK" Width="58px" /></td>
                    </tr>
                </table>
            </asp:Panel>
            <table>
                <tr>
                    <td style="width: 100px; height: 41px">
                        Rule Active?</td>
                    <td style="width: 105px; height: 41px">
                        <asp:CheckBox ID="activeCheckBox" runat="server" Checked='<%# Bind("active") %>'
                            Enabled="False" /></td>
                </tr>
          <tr>
                    <td style="width: 100px; height: 41px">
                        Rule Active?</td>
                    <td style="width: 105px; height: 41px">
                                   unit_type:
            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("unit_type") %>' />
                    </td>
                </tr>
 
            </table>
            <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCalculate" OkControlID="btnCalcOK" PopupControlID="pnlCalc" DropShadow="true" PopupDragHandleControlID="pnlCalcDragPanel">
            </cc1:ModalPopupExtender>
            <br />
            <table>
                <tr>
                    <td style="width: 100px">
                        Rule ID</td>
                </tr>
                <tr>
                    <td style="width: 100px">
                        <asp:Label ID="product_rules_idLabel" runat="server" Enabled="False" Text='<%# Eval("product_rules_id") %>'></asp:Label></td>
                </tr>
            </table>
            <br />
            <br />
            ModBy:
            <asp:Label ID="LastModByLabel" runat="server" Text='<%# Bind("LastModBy") %>'></asp:Label><br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Edit"></asp:LinkButton>
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                Text="Delete"></asp:LinkButton>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="New"></asp:LinkButton>
        </ItemTemplate>
        <PagerSettings Mode="NextPreviousFirstLast" NextPageText="Next" PreviousPageText="Previous" />
    </asp:FormView>
    <asp:ObjectDataSource ID="odsRules" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="dsRulesTableAdapters.dtRulesTableAdapter" UpdateMethod="Update" OnSelecting="odsRules_Selecting">
        <DeleteParameters>
            <asp:ControlParameter ControlID="FormView1" Name="product_rules_id" PropertyName="SelectedValue"
                Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="product_rules_id" Type="Int32" />
            <asp:Parameter Name="supplier_im_id" Type="String" />
            <asp:Parameter Name="product_id" Type="String" />
            <asp:Parameter Name="company_id" Type="Int32" />
            <asp:Parameter Name="effective_date" Type="DateTime" />
            <asp:Parameter Name="base_cost" Type="Double" />
            <asp:Parameter Name="capability_support_cost" Type="Double" />
            <asp:Parameter Name="service_cost" Type="Double" />
            <asp:Parameter Name="cc_im" Type="String" />
            <asp:Parameter Name="cc_pct" Type="Double" />
            <asp:Parameter Name="qh_im" Type="String" />
            <asp:Parameter Name="qh_margin" Type="Double" />
            <asp:Parameter Name="qh_pct" Type="Double" />
            <asp:Parameter Name="active" Type="Boolean" />
            <asp:Parameter Name="unit_type" Type="String" />
            <asp:Parameter Name="LastModBy" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="supplier_im_id" Type="String" />
            <asp:Parameter Name="product_id" Type="String" />
            <asp:Parameter Name="company_id" Type="Int32" />
            <asp:Parameter Name="effective_date" Type="DateTime" />
            <asp:Parameter Name="base_cost" Type="Double" />
            <asp:Parameter Name="capability_support_cost" Type="Double" />
            <asp:Parameter Name="service_cost" Type="Double" />
            <asp:Parameter Name="cc_im" Type="String" />
            <asp:Parameter Name="cc_pct" Type="Double" />
            <asp:Parameter Name="qh_im" Type="String" />
            <asp:Parameter Name="qh_margin" Type="Double" />
            <asp:Parameter Name="qh_pct" Type="Double" />
            <asp:Parameter Name="active" Type="Boolean" />
            <asp:Parameter Name="unit_type" Type="String" />
            <asp:Parameter Name="LastModBy" Type="String" />
        </InsertParameters>
0
 
KBSLPDevAuthor Commented:
Found the issue :
http://forums.asp.net/t/969187.aspx
>> From site article
"
asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"

InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"

TypeName="PaintingsTableAdapters.proc_PaintingsLoadAllTableAdapter" UpdateMethod="Update">

The bold section represent the problematic section. Modify the "OldValuesParameterFormatString" value from "original_{0}" to "{0}". Et voilĂ  !!!

No more "Could not find a non-generic...." error.

"
0
 
Computer101Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now