开发者

ItemUpdating NewValues Missing Parameter

开发者 https://www.devze.com 2023-02-24 09:09 出处:网络
I have a formview with several data items that works perfectly except for a single parameter that will not update with the rest of them.The formview\'s datasource updateparameter is set to do nothing

I have a formview with several data items that works perfectly except for a single parameter that will not update with the rest of them. The formview's datasource updateparameter is set to do nothing so that I can handle the update in codebehind. Every item works fine, except for one parameter ("salesprice") that is missing in the OldValues and NewValues argument of the ItemUpdating event of the formview. The data DOES pull in to the textbox as it should, formatted properly and all.

I've attached the html, SQL (for getLoanData()), and the codebehind.

Why would every parameter exist in the New/OldValue arguments except the "salesprice" parameter? I've tried populating the textbox without the formatstring, and it's still missing. Is there something about a money SQL datatype that might cause a problem?

HTML:

<asp:FormView ID="fvLoanDetails" runat="server" DataKeyNames="orderid" 
DataSourceID="sqlLoanDetails" Width="100%">
<ItemTemplate>
    ...
</ItemTemplate>
<EditItemTemplate>
    <table class="orderSectionHeader">
        <tr>
            <td style="padding-left:10px;">
                <h2>Loan Details</h2>
            </td>
            <td style="text-align:right;">    
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
                <asp:Button ID="bvnSave" runat="server" Text="Save" CommandName="Update" />
            </td>
        </tr>
    </table>
    <table class="orderSection">
        <tr>
            <td class="orderHeader" style="vertical-align:top;">
                Loan Number
            </td>
            <td>
                <asp:Label ID="lblLoanNumber" CssClass="orderData" runat="server" 
                    Text='<%# Bind("loannumber") %>' />
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Business Channel
            </td>
            <td>
                <asp:DropDownList ID="ddlBusinessChannel" runat="server" 
                    DataSourceID="sqlBusinessChannels" DataTextField="BusinessChannel" 
                    DataValueField="BusinessChannel" SelectedValue='<%# Bind("businesschannel") %>'>
                </asp:DropDownList>                                
                <asp:SqlDataSource ID="sqlBusinessChannels" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:Jade_4 %>" 
                    SelectCommand="SELECT DISTINCT [BusinessChannel] FROM [Loans] ORDER BY [BusinessChannel]">
                </asp:SqlDataSource>                                
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Loan Type
            </td>
            <td>
                <asp:DropDownList ID="ddlLoanType" runat="server" 
                    DataSourceID="sqlLoanType" DataTextField="LoanType" 
                    DataValueField="LoanType" SelectedValue='<%# Bind("loantype") %>'>
                </asp:DropDownList>                                
                <asp:SqlDataSource ID="sqlLoanType" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:Jade_4 %>" 
                    SelectCommand="SELECT DISTINCT [LoanType] FROM [Loans] ORDER BY [LoanType]">
                </asp:SqlDataSource>  
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Purpose
            </td>
            <td>
                <asp:DropDownList ID="ddlPurpose" runat="server" 
                    SelectedValue='<%# Bind("purpose") %>'>
                    <asp:ListItem Text="Purchase" Value="False" />
                    <asp:ListItem Text="Refinance" Value="True" />
                </asp:DropDownList>              
            </td>
        </tr>
        <tr id="trSalesPrice" runat="server">
            <td class="orderHeader">
                Sales Price
            </td>
            <td>
                <asp:TextBox ID="txtSalesPrice" CssClass="orderData" runat="server" Width="100"
                    Text='<%# Bind("salesprice", "{0:F2}") %>' />
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Borrower
            </td>
            <td>
                <table cellspacing="0">
                    <tr style="font-size:8pt;padding-bottom:0px;">
                        <td>First</td><td>Last</td>
                    </tr>
                    <tr>
                        <td>
                            <asp:TextBox ID="txtBFirst" CssClass="orderData" runat="server" Width="80" 
                                Text='<%# Bind("firstname") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="txtBLast" CssClass="orderData" runat="server" Width="120" 
                                Text='<%# Bind("lastname") %>' />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Borrower Email
            </td>
            <td>
                <asp:TextBox ID="txtEmail" CssClass="orderData" runat="server" Width="200"
                    Text='<%# Bind("email") %>' />
            </td>
        </tr>
        <tr>
            <td class="orderHeader" style="vertical-align:top;">
                Mailing Address
            </td>
            <td>
                <table cellspacing="0">
                    <tr style="font-size:8pt;padding-bottom:0px;">
                        <td colspan="3">Address</td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <asp:TextBox ID="txtAddress" CssClass="orderData" runat="server" Width="200" 
                                Text='<%# Bind("address") %>' />
                        </td>
                    </tr>
                    <tr style="font-size:8pt;padding-bottom:0px;">
                        <td>City</td><td>State</td><td>Zip</td>
                    </tr>
                    <tr>
                        <td>
                            <asp:TextBox ID="txtCity" CssClass="orderData" runat="server" Width="100"
                                Text='<%# Bind("city") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="txtState" CssClass="orderData" runat="server" Width="30" 
                                Text='<%# Bind("state") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="txtZip" CssClass="orderData" runat="server" Width="50" 
                                Text='<%# Bind("zip") %>' />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Borrower Primary
            </td>
            <td>
                <asp:TextBox ID="txtBPhone" CssClass="orderData" runat="server" 
                    Text='<%# Bind("phone1", "{0:(###) ###-####}")%>' />
            </td>
        </tr>
        <tr>
            <td class="orderHeader">
                Borrower Secondary
            </td>
            <td>
                <asp:TextBox ID="txtBCell" CssClass="orderData" runat="server" 
                    Text='<%# Bind("phone2", "{0:(###) ###-####}")%>' />
            </td>
        </tr>
    </table>
</EditItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="sqlLoanDetails" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Jade_4 %>" 
    SelectCommand="select @orderid as orderid, * from dbo.getLoanData(@orderid)"
    UpdateCommand="select @orderid">
    <SelectParameters>
        <asp:ControlParameter ControlID="hdnOrderID" Name="orderid" 
            PropertyName="Value" DefaultValue="0" />
    </SelectParameters>          
</asp:SqlDataSource>

VB.NET:

Protected Sub fvLoanDetails_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles fvLoanDetails.ItemUp开发者_如何学Pythondating

    Dim o As Order = DAL.GetOrderById(hdnOrderID.Value)
    Dim l As Loan = DAL.GetLoanByLoanID(o.LoanID)
    Dim b As Contact = DAL.GetContactById(l.BorrowerContactID)

    l.BusinessChannel = e.NewValues("businesschannel")
    l.LoanType = e.NewValues("loantype")
    l.Purpose = e.NewValues("purpose")
    l.SalesPrice = e.NewValues("salesprice")
    DAL.UpdateLoan(l)

    b.FirstName = e.NewValues("firstname")
    b.LastName = e.NewValues("lastname")
    b.Address = e.NewValues("address")
    b.City = e.NewValues("city")
    b.State = e.NewValues("state")
    b.Zip = e.NewValues("zip")
    b.Phone = e.NewValues("phone1")
    b.Cell = e.NewValues("phone2")
    DAL.UpdateContact(b)

End Sub

SQL:

    select 
l.loannumber, l.businesschannel, l.loantype, l.purpose, l.salesprice, b.firstname, b.lastname, b.email, 
b.address, b.city, b.state, b.zip, b.phone as phone1, b.cell as phone2,
dbo.formataddressweb(b.address, '', b.city, b.state, b.zip) as mailingaddress          from loans l 
join orders o on o.orderid=@orderid
join contacts b on l.borrowercontactid=b.contactid
where l.loanid=(select loanid from orders where orderid=@orderid)


Have you tried a different format string?

Text='<%# Bind("salesprice", "{0:C}") %>'
0

精彩评论

暂无评论...
验证码 换一张
取 消