none
sqldatasource中的某个写法有点特殊的值,在formview中显示出错 RRS feed

  • 问题

  • -----------------------  这个@SumMR通过前台和后台的代码显示----------------------------- 

    <SelectParameters>
                                <asp:QueryStringParameter Name="PRID" QueryStringField="PRID" Type="Int32" />
                                <asp:Parameter Name="SumMR" Type="Int32"  Direction="Output"/>
                            </SelectParameters>
    protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {
            string SumMR = e.Command.Parameters["@SumMR"].Value.ToString();
            Label_SumMR.Text = SumMR;
            ((Label)this.FormView1.FindControl("Label_SumMR_InFV_EditItemTemplate")).Text = SumMR;
        --------------------------------图------------------------------------

    --------------------------------------完整前台代码-------------------------------

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Try_201402ReceCount_Default2" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .style1
            {
                width: 100%;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <table cellpadding="0" cellspacing="0" class="style1">
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label_SumMR" runat="server" ></asp:Label>
                        <asp:FormView ID="FormView1" runat="server" DataKeyNames="PRID" 
                            DataSourceID="SqlDataSource1">
                            <EditItemTemplate>
                                <asp:Label ID="Label_SumMR_InFV_EditItemTemplate" runat="server" ></asp:Label>
                                PRID:
                                <asp:Label ID="PRIDLabel1" runat="server" Text='<%# Eval("PRID") %>' />
                                <br />
                                ManageProjectR:
                                <asp:TextBox ID="ManageProjectRTextBox" runat="server" 
                                    Text='<%# Bind("ManageProjectR") %>' />
                                <br />
                                PropertyCityR:
                                <asp:TextBox ID="PropertyCityRTextBox" runat="server" 
                                    Text='<%# Bind("PropertyCityR") %>' />
                                <br />
                                PropertyRoadR:
                                <asp:TextBox ID="PropertyRoadRTextBox" runat="server" 
                                    Text='<%# Bind("PropertyRoadR") %>' />
                                <br />
                                PropertyAddressR:
                                <asp:TextBox ID="PropertyAddressRTextBox" runat="server" 
                                    Text='<%# Bind("PropertyAddressR") %>' />
                                <br />
                                MonthRentR01:
                                <asp:TextBox ID="MonthRentR01TextBox" runat="server" 
                                    Text='<%# Bind("MonthRentR01") %>' />
                                <br />
                                MonthRentR02:
                                <asp:TextBox ID="MonthRentR02TextBox" runat="server" 
                                    Text='<%# Bind("MonthRentR02") %>' />
                                <br />
                                MonthRentR03:
                                <asp:TextBox ID="MonthRentR03TextBox" runat="server" 
                                    Text='<%# Bind("MonthRentR03") %>' />
                                <br />
                                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                                    CommandName="Update" Text="更新" />
                                &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                                    CausesValidation="False" CommandName="Cancel" Text="取消" />
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                ManageProjectR:
                                <asp:TextBox ID="ManageProjectRTextBox0" runat="server" 
                                    Text='<%# Bind("ManageProjectR") %>' />
                                <br />
                                PropertyCityR:
                                <asp:TextBox ID="PropertyCityRTextBox0" runat="server" 
                                    Text='<%# Bind("PropertyCityR") %>' />
                                <br />
                                PropertyRoadR:
                                <asp:TextBox ID="PropertyRoadRTextBox0" runat="server" 
                                    Text='<%# Bind("PropertyRoadR") %>' />
                                <br />
                                PropertyAddressR:
                                <asp:TextBox ID="PropertyAddressRTextBox0" runat="server" 
                                    Text='<%# Bind("PropertyAddressR") %>' />
                                <br />
                                MonthRentR01:
                                <asp:TextBox ID="MonthRentR01TextBox0" runat="server" 
                                    Text='<%# Bind("MonthRentR01") %>' />
                                <br />
                                MonthRentR02:
                                <asp:TextBox ID="MonthRentR02TextBox0" runat="server" 
                                    Text='<%# Bind("MonthRentR02") %>' />
                                <br />
                                MonthRentR03:
                                <asp:TextBox ID="MonthRentR03TextBox0" runat="server" 
                                    Text='<%# Bind("MonthRentR03") %>' />
                                <br />
                                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                                    CommandName="Insert" Text="插入" />
                                &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                                    CausesValidation="False" CommandName="Cancel" Text="取消" />
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label_SumMR_InFV_ItemTemplate" runat="server" ></asp:Label>
                                PRID:
                                <asp:Label ID="PRIDLabel" runat="server" Text='<%# Eval("PRID") %>' />
                                <br />
                                ManageProjectR:
                                <asp:Label ID="ManageProjectRLabel" runat="server" 
                                    Text='<%# Bind("ManageProjectR") %>' />
                                <br />
                                PropertyCityR:
                                <asp:Label ID="PropertyCityRLabel" runat="server" 
                                    Text='<%# Bind("PropertyCityR") %>' />
                                <br />
                                PropertyRoadR:
                                <asp:Label ID="PropertyRoadRLabel" runat="server" 
                                    Text='<%# Bind("PropertyRoadR") %>' />
                                <br />
                                PropertyAddressR:
                                <asp:Label ID="PropertyAddressRLabel" runat="server" 
                                    Text='<%# Bind("PropertyAddressR") %>' />
                                <br />
                                MonthRentR01:
                                <asp:Label ID="MonthRentR01Label" runat="server" 
                                    Text='<%# Bind("MonthRentR01") %>' />
                                <br />
                                MonthRentR02:
                                <asp:Label ID="MonthRentR02Label" runat="server" 
                                    Text='<%# Bind("MonthRentR02") %>' />
                                <br />
                                MonthRentR03:
                                <asp:Label ID="MonthRentR03Label" runat="server" 
                                    Text='<%# Bind("MonthRentR03") %>' />
                                <br />
                                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                                    CommandName="Edit" Text="编辑" />
                                &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                                    CommandName="Delete" Text="删除" />
                                &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                                    CommandName="New" Text="新建" />
                            </ItemTemplate>
                        </asp:FormView>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %>" 
                            DeleteCommand="DELETE FROM [ReceivableTable] WHERE [PRID] = @PRID" 
                            
                            InsertCommand="INSERT INTO [ReceivableTable] ([ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR]) VALUES (@ManageProjectR, @PropertyCityR, @PropertyRoadR, @PropertyAddressR)" SelectCommand="SELECT [PRID], [ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR], 
    MonthRentR01,MonthRentR02,MonthRentR03
    FROM [ReceivableTable] 
    WHERE ([PRID] = @PRID)
    ;
    select @SumMR=ISNULL(MonthRentR01,0)+ISNULL (MonthRentR02,0)+ISNULL (MonthRentR03,0)
    FROM [ReceivableTable] 
    WHERE ([PRID] = @PRID)" 
                            
                            UpdateCommand="UPDATE [ReceivableTable] SET [ManageProjectR] = @ManageProjectR, [PropertyCityR] = @PropertyCityR, [PropertyRoadR] = @PropertyRoadR, [PropertyAddressR] = @PropertyAddressR WHERE [PRID] = @PRID" 
                            onselected="SqlDataSource1_Selected">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="PRID" QueryStringField="PRID" Type="Int32" />
                                <asp:Parameter Name="SumMR" Type="Int32"  Direction="Output"/>
                            </SelectParameters>
                            <DeleteParameters>
                                <asp:Parameter Name="PRID" Type="Int32" />
                            </DeleteParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="ManageProjectR" Type="String" />
                                <asp:Parameter Name="PropertyCityR" Type="String" />
                                <asp:Parameter Name="PropertyRoadR" Type="String" />
                                <asp:Parameter Name="PropertyAddressR" Type="String" />
                                <asp:Parameter Name="PRID" Type="Int32" />
                            </UpdateParameters>
                            <InsertParameters>
                                <asp:Parameter Name="ManageProjectR" Type="String" />
                                <asp:Parameter Name="PropertyCityR" Type="String" />
                                <asp:Parameter Name="PropertyRoadR" Type="String" />
                                <asp:Parameter Name="PropertyAddressR" Type="String" />
                            </InsertParameters>
                        </asp:SqlDataSource>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        
        </div>
        </form>
    </body>
    </html>

    -------------------------------------------后台代码-----------------------------------------------

    public partial class Try_201402ReceCount_Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {
            string SumMR = e.Command.Parameters["@SumMR"].Value.ToString();
            Label_SumMR.Text = SumMR;
            ((Label)this.FormView1.FindControl("Label_SumMR_InFV_EditItemTemplate")).Text = SumMR;
        }
    }


    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!


    2014年2月19日 4:36

全部回复