none
代码很长!问题很简单!为什么GridView的编辑、更新、删除不起作用?哪里写错了? RRS feed

  • 问题

  • 为什么GridView的编辑、更新、删除不起作用?可能是SqlDataSource_Search后面的Sql语句有错!但我反复检查了也找不到毛病!谁能发现错误在哪里么??? ===============================前台代码========================= <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ContractManage.aspx.cs" Inherits="ContractTable_ContractManage" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
     
      按合同号查询  <asp:TextBox ID="TextBox_ContractNumber" runat="server" AutoPostBack="True"></asp:TextBox> 所在城市: <asp:DropDownList ID="DropDownList_City" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource_City" DataTextField="City" DataValueField="City"> <asp:ListItem Value="-1">-全部-</asp:ListItem> </asp:DropDownList>   所在路段:<asp:DropDownList ID="DropDownList_Road" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource_Road" DataTextField="Road" DataValueField="Road"> <asp:ListItem Value="-1">-全部-</asp:ListItem> </asp:DropDownList>     门牌号:<asp:DropDownList ID="DropDownList_Address" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource_Address" DataTextField="Address" DataValueField="Address"> <asp:ListItem Value="-1">-全部-</asp:ListItem> </asp:DropDownList>   合同起始日: <asp:TextBox ID="TextBox_LeaseDateForm" runat="server" AutoPostBack="True"></asp:TextBox>   合同终止日<asp:TextBox ID="TextBox_LeaseDateTo" runat="server" AutoPostBack="True"></asp:TextBox> <asp:Button ID="Button_F5" runat="server" onclick="Button_F5_Click" style="height: 26px; width: 50px" Text="-刷新-" />
     
     
    <asp:GridView ID="GridView_Search" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource_Search" DataKeyNames="ContractNumber" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> <asp:BoundField DataField="SumbitNumber" HeaderText="SumbitNumber" SortExpression="SumbitNumber" /> <asp:BoundField DataField="ContractTypeDetail" HeaderText="ContractTypeDetail" SortExpression="ContractTypeDetail" /> <asp:BoundField DataField="ContractType" HeaderText="ContractType" SortExpression="ContractType" /> <asp:BoundField DataField="SubjectMatter" HeaderText="SubjectMatter" SortExpression="SubjectMatter" /> <asp:BoundField DataField="ContractNumber" HeaderText="ContractNumber" SortExpression="ContractNumber" ReadOnly="True" /> <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> <asp:BoundField DataField="Road" HeaderText="Road" SortExpression="Road" /> <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /> <asp:BoundField DataField="Address1" HeaderText="Address1" ReadOnly="True" SortExpression="Address1" /> <asp:BoundField DataField="OppositeSide" HeaderText="OppositeSide" SortExpression="OppositeSide" /> <asp:BoundField DataField="ManageProject" HeaderText="ManageProject" SortExpression="ManageProject" /> <asp:BoundField DataField="LeaseDateSign" HeaderText="LeaseDateSign" SortExpression="LeaseDateSign" /> <asp:BoundField DataField="LeaseDateFrom" HeaderText="LeaseDateFrom" SortExpression="LeaseDateFrom" /> <asp:BoundField DataField="LeaseDateTo" HeaderText="LeaseDateTo" SortExpression="LeaseDateTo" /> <asp:BoundField DataField="PerformState" HeaderText="PerformState" SortExpression="PerformState" /> <asp:CheckBoxField DataField="SafetyContract" HeaderText="SafetyContract" SortExpression="SafetyContract" /> <asp:CheckBoxField DataField="FamilyPlanningContract" HeaderText="FamilyPlanningContract" SortExpression="FamilyPlanningContract" /> <asp:CheckBoxField DataField="FoodContract" HeaderText="FoodContract" SortExpression="FoodContract" /> <asp:BoundField DataField="ContractResponsible" HeaderText="ContractResponsible" SortExpression="ContractResponsible" /> <asp:BoundField DataField="ContractChange" HeaderText="ContractChange" SortExpression="ContractChange" /> <asp:BoundField DataField="ReferencePrice" HeaderText="ReferencePrice" SortExpression="ReferencePrice" /> <asp:BoundField DataField="ReferencePriceRemarks" HeaderText="ReferencePriceRemarks" SortExpression="ReferencePriceRemarks" /> <asp:BoundField DataField="ContractRemarks" HeaderText="ContractRemarks" SortExpression="ContractRemarks" /> <asp:BoundField DataField="TypeOfPayment" HeaderText="TypeOfPayment" SortExpression="TypeOfPayment" /> <asp:BoundField DataField="MonthRent" HeaderText="MonthRent" SortExpression="MonthRent" /> <asp:BoundField DataField="RealityRent" HeaderText="RealityRent" SortExpression="RealityRent" /> <asp:BoundField DataField="RealityYearRent" HeaderText="RealityYearRent" SortExpression="RealityYearRent" /> <asp:BoundField DataField="SumRent" HeaderText="SumRent" SortExpression="SumRent" /> <asp:BoundField DataField="LeaseAssureMoney" HeaderText="LeaseAssureMoney" SortExpression="LeaseAssureMoney" /> <asp:BoundField DataField="RateOfRise" HeaderText="RateOfRise" SortExpression="RateOfRise" /> </Columns> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView>
     
     
     
    <asp:SqlDataSource ID="SqlDataSource_Search" runat="server" ConnectionString="<%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %>" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [SumbitNumber], [ContractTypeDetail], [ContractType], [SubjectMatter], [ContractNumber], [City], [Road], [Address],[City]+[Road]+ [Address] as [Address1], [OppositeSide], [ManageProject], [LeaseDateSign], [LeaseDateFrom], [LeaseDateTo], [PerformState], [SafetyContract], [FamilyPlanningContract], [FoodContract], [ContractResponsible], [ContractChange], [ReferencePrice], [ReferencePriceRemarks], [ContractRemarks], [TypeOfPayment], [MonthRent], [RealityRent], [RealityYearRent], [SumRent], [LeaseAssureMoney], [RateOfRise] FROM ContractTable WHERE (ISNULL(@ContractNumber, N'') = '' OR ISNULL(ContractNumber, N'') LIKE '%' + @ContractNumber + '%') AND (ISNULL(@City, N'') = '-1') AND (ISNULL(@Road, N'') = '-1') AND (ISNULL(@Address, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) OR (ISNULL(@City, N'') = '-1') AND (ISNULL(@Address, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (Road = @Road) OR (ISNULL(@Road, N'') = '-1') AND (ISNULL(@Address, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (City = @City) OR (ISNULL(@Address, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (Road = @Road) AND (City = @City) OR (ISNULL(@City, N'') = '-1') AND (ISNULL(@Road, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (Address = @Address) OR (ISNULL(@City, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (Road = @Road) AND (Address = @Address) OR (ISNULL(@Road, N'') = '-1') AND (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (City = @City) AND (Address = @Address) OR (LeaseDateFrom >= @LeaseDateFrom) AND (LeaseDateTo <= @LeaseDateTo) AND (Road = @Road) AND (City = @City) AND (Address = @Address)" DeleteCommand="DELETE FROM ContractTable WHERE (ContractNumber = @original_ContractNumber) AND (SumbitNumber = @original_SumbitNumber OR SumbitNumber IS NULL AND @original_SumbitNumber IS NULL) AND (ContractTypeDetail = @original_ContractTypeDetail OR ContractTypeDetail IS NULL AND @original_ContractTypeDetail IS NULL) AND (ContractType = @original_ContractType OR ContractType IS NULL AND @original_ContractType IS NULL) AND (SubjectMatter = @original_SubjectMatter OR SubjectMatter IS NULL AND @original_SubjectMatter IS NULL) AND (City = @original_City OR City IS NULL AND @original_City IS NULL) AND (Road = @original_Road OR Road IS NULL AND @original_Road IS NULL) AND (Address = @original_Address OR Address IS NULL AND @original_Address IS NULL) AND (OppositeSide = @original_OppositeSide OR OppositeSide IS NULL AND @original_OppositeSide IS NULL) AND (ManageProject = @original_ManageProject OR ManageProject IS NULL AND @original_ManageProject IS NULL) AND (LeaseDateSign = @original_LeaseDateSign OR LeaseDateSign IS NULL AND @original_LeaseDateSign IS NULL) AND (LeaseDateFrom = @original_LeaseDateFrom OR LeaseDateFrom IS NULL AND @original_LeaseDateFrom IS NULL) AND (LeaseDateTo = @original_LeaseDateTo OR LeaseDateTo IS NULL AND @original_LeaseDateTo IS NULL) AND (PerformState = @original_PerformState OR PerformState IS NULL AND @original_PerformState IS NULL) AND (SafetyContract = @original_SafetyContract OR SafetyContract IS NULL AND @original_SafetyContract IS NULL) AND (FamilyPlanningContract = @original_FamilyPlanningContract OR FamilyPlanningContract IS NULL AND @original_FamilyPlanningContract IS NULL) AND (FoodContract = @original_FoodContract OR FoodContract IS NULL AND @original_FoodContract IS NULL) AND (ContractResponsible = @original_ContractResponsible OR ContractResponsible IS NULL AND @original_ContractResponsible IS NULL) AND (ContractChange = @original_ContractChange OR ContractChange IS NULL AND @original_ContractChange IS NULL) AND (ReferencePrice = @original_ReferencePrice OR ReferencePrice IS NULL AND @original_ReferencePrice IS NULL) AND (ReferencePriceRemarks = @original_ReferencePriceRemarks OR ReferencePriceRemarks IS NULL AND @original_ReferencePriceRemarks IS NULL) AND (ContractRemarks = @original_ContractRemarks OR ContractRemarks IS NULL AND @original_ContractRemarks IS NULL) AND (TypeOfPayment = @original_TypeOfPayment OR TypeOfPayment IS NULL AND @original_TypeOfPayment IS NULL) AND (MonthRent = @original_MonthRent OR MonthRent IS NULL AND @original_MonthRent IS NULL) AND (RealityRent = @original_RealityRent OR RealityRent IS NULL AND @original_RealityRent IS NULL) AND (SumRent = @original_SumRent OR SumRent IS NULL AND @original_SumRent IS NULL) AND (RealityYearRent = @original_RealityYearRent OR RealityYearRent IS NULL AND @original_RealityYearRent IS NULL) AND (LeaseAssureMoney = @original_LeaseAssureMoney OR LeaseAssureMoney IS NULL AND @original_LeaseAssureMoney IS NULL) AND (RateOfRise = @original_RateOfRise OR RateOfRise IS NULL AND @original_RateOfRise IS NULL)" InsertCommand="INSERT INTO [ContractTable] ([SumbitNumber],[ContractTypeDetail], [ContractType],[SubjectMatter],[SubjectState], [ContractNumber], [City], [Road], [Address],[OppositeSide], [ManageProject], [LeaseDateSign], [LeaseDateFrom], [LeaseDateTo],[PerformState], [SafetyContract], [FamilyPlanningContract], [FoodContract], [ContractResponsible], [ContractChange], [ReferencePrice], [ReferencePriceRemarks], [ContractRemarks], [TypeOfPayment], [MonthRent],[RealityRent] [RealityYearRent],[SumRent], [LeaseAssureMoney], [RateOfRise]) VALUES (@SumbitNumber,@ContractTypeDetail, @ContractType,@SubjectMatter,@SubjectState, @ContractNumber, @City, @Road, @Address,@OppositeSide, @ManageProject, @LeaseDateSign, @LeaseDateFrom, @LeaseDateTo,@PerformState, @SafetyContract, @FamilyPlanningContract, @FoodContract, @ContractResponsible, @ContractChange, @ReferencePrice, @ReferencePriceRemarks, @ContractRemarks, @TypeOfPayment, @MonthRent, @RealityRent,@RealityYearRent,@SumRent, @LeaseAssureMoney, @RateOfRise)" UpdateCommand="UPDATE [ContractTable] SET [SumbitNumber] = @SumbitNumber,[ContractTypeDetail]=@ContractTypeDetail,[ContractType] = @ContractType, [SubjectMatter]=@SubjectMatter,[City] = @City, [Road] = @Road, [Address] = @Address, [OppositeSide]=@OppositeSide,[ManageProject] = @ManageProject, [LeaseDateSign] = @LeaseDateSign, [LeaseDateFrom] = @LeaseDateFrom, [LeaseDateTo] = @LeaseDateTo,[PerformState]=@PerformState, [SafetyContract] = @SafetyContract, [FamilyPlanningContract] = @FamilyPlanningContract, [FoodContract] = @FoodContract, [ContractResponsible] = @ContractResponsible, [ContractChange] = @ContractChange, [ReferencePrice] = @ReferencePrice, [ReferencePriceRemarks] = @ReferencePriceRemarks, [ContractRemarks] = @ContractRemarks, [TypeOfPayment] = @TypeOfPayment, [MonthRent] = @MonthRent, [RealityYearRent] = @RealityYearRent,[SumRent]=@SumRent, [LeaseAssureMoney] = @LeaseAssureMoney, [RateOfRise] = @RateOfRise WHERE [ContractNumber] = @original_ContractNumber AND (([SumbitNumber] = @original_SumbitNumber) OR ([SumbitNumber] IS NULL AND @original_SumbitNumber IS NULL)) AND (([ContractTypeDetail] = @original_ContractTypeDetail) OR ([ContractTypeDetail] IS NULL AND @original_ContractTypeDetail IS NULL)) AND (([ContractType] = @original_ContractType) OR ([ContractType] IS NULL AND @original_ContractType IS NULL)) AND (([SubjectMatter] = @original_SubjectMatter) OR ([SubjectMatter] IS NULL AND @original_SubjectMatter IS NULL)) AND (([City] = @original_City) OR ([City] IS NULL AND @original_City IS NULL)) AND (([Road] = @original_Road) OR ([Road] IS NULL AND @original_Road IS NULL)) AND (([Address] = @original_Address) OR ([Address] IS NULL AND @original_Address IS NULL)) AND (([OppositeSide] = @original_OppositeSide) OR ([OppositeSide] IS NULL AND @original_OppositeSide IS NULL)) AND (([ManageProject] = @original_ManageProject) OR ([ManageProject] IS NULL AND @original_ManageProject IS NULL)) AND (([LeaseDateSign] = @original_LeaseDateSign) OR ([LeaseDateSign] IS NULL AND @original_LeaseDateSign IS NULL)) AND (([LeaseDateFrom] = @original_LeaseDateFrom) OR ([LeaseDateFrom] IS NULL AND @original_LeaseDateFrom IS NULL)) AND (([LeaseDateTo] = @original_LeaseDateTo) OR ([LeaseDateTo] IS NULL AND @original_LeaseDateTo IS NULL)) AND (([OppositeSide] = @original_OppositeSide) OR ([OppositeSide] IS NULL AND @original_OppositeSide IS NULL)) AND (([SafetyContract] = @original_SafetyContract) OR ([SafetyContract] IS NULL AND @original_SafetyContract IS NULL)) AND (([FamilyPlanningContract] = @original_FamilyPlanningContract) OR ([FamilyPlanningContract] IS NULL AND @original_FamilyPlanningContract IS NULL)) AND (([FoodContract] = @original_FoodContract) OR ([FoodContract] IS NULL AND @original_FoodContract IS NULL)) AND (([ContractResponsible] = @original_ContractResponsible) OR ([ContractResponsible] IS NULL AND @original_ContractResponsible IS NULL)) AND (([ContractChange] = @original_ContractChange) OR ([ContractChange] IS NULL AND @original_ContractChange IS NULL)) AND (([ReferencePrice] = @original_ReferencePrice) OR ([ReferencePrice] IS NULL AND @original_ReferencePrice IS NULL)) AND (([ReferencePriceRemarks] = @original_ReferencePriceRemarks) OR ([ReferencePriceRemarks] IS NULL AND @original_ReferencePriceRemarks IS NULL)) AND (([ContractRemarks] = @original_ContractRemarks) OR ([ContractRemarks] IS NULL AND @original_ContractRemarks IS NULL)) AND (([TypeOfPayment] = @original_TypeOfPayment) OR ([TypeOfPayment] IS NULL AND @original_TypeOfPayment IS NULL)) AND (([MonthRent] = @original_MonthRent) OR ([MonthRent] IS NULL AND @original_MonthRent IS NULL)) AND (([RealityRent] = @original_RealityRent) OR ([RealityRent] IS NULL AND @original_RealityRent IS NULL)) AND (([RealityYearRent] = @original_RealityYearRent) OR ([RealityYearRent] IS NULL AND @original_RealityYearRent IS NULL)) AND (([SumRent] = @original_SumRent) OR ([SumRent] IS NULL AND @original_SumRent IS NULL)) AND (([LeaseAssureMoney] = @original_LeaseAssureMoney) OR ([LeaseAssureMoney] IS NULL AND @original_LeaseAssureMoney IS NULL)) AND (([RateOfRise] = @original_RateOfRise) OR ([RateOfRise] IS NULL AND @original_RateOfRise IS NULL))"> <SelectParameters> <asp:ControlParameter ControlID="TextBox_ContractNumber" Name="ContractNumber" PropertyName="Text" ConvertEmptyStringToNull="False" /> <asp:ControlParameter ControlID="DropDownList_City" Name="City" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="DropDownList_Road" Name="Road" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="DropDownList_Address" Name="Address" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="TextBox_LeaseDateForm" Name="LeaseDateFrom" PropertyName="Text" DbType="Date" DefaultValue="2000-01-01" /> <asp:ControlParameter ControlID="TextBox_LeaseDateTo" Name="LeaseDateTo" PropertyName="Text" DbType="Date" DefaultValue="2100-01-01" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="original_ContractNumber" /> <asp:Parameter Name="original_SumbitNumber" /> <asp:Parameter Name="original_ContractTypeDetail" /> <asp:Parameter Name="original_ContractType" /> <asp:Parameter Name="original_SubjectMatter" /> <asp:Parameter Name="original_City" /> <asp:Parameter Name="original_Road" /> <asp:Parameter Name="original_Address" /> <asp:Parameter Name="original_OppositeSide" /> <asp:Parameter Name="original_ManageProject" /> <asp:Parameter Name="original_LeaseDateSign" /> <asp:Parameter Name="original_LeaseDateFrom" /> <asp:Parameter Name="original_LeaseDateTo" /> <asp:Parameter Name="original_PerformState" /> <asp:Parameter Name="original_SafetyContract" /> <asp:Parameter Name="original_FamilyPlanningContract" /> <asp:Parameter Name="original_FoodContract" /> <asp:Parameter Name="original_ContractResponsible" /> <asp:Parameter Name="original_ContractChange" /> <asp:Parameter Name="original_ReferencePrice" /> <asp:Parameter Name="original_ReferencePriceRemarks" /> <asp:Parameter Name="original_ContractRemarks" /> <asp:Parameter Name="original_TypeOfPayment" /> <asp:Parameter Name="original_MonthRent" /> <asp:Parameter Name="original_RealityRent" /> <asp:Parameter Name="original_SumRent" /> <asp:Parameter Name="original_RealityYearRent" /> <asp:Parameter Name="original_LeaseAssureMoney" /> <asp:Parameter Name="original_RateOfRise" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="SumbitNumber" /> <asp:Parameter Name="ContractTypeDetail" /> <asp:Parameter Name="ContractType" /> <asp:Parameter Name="SubjectMatter" /> <asp:Parameter Name="City" /> <asp:Parameter Name="Road" /> <asp:Parameter Name="Address" /> <asp:Parameter Name="OppositeSide" /> <asp:Parameter Name="ManageProject" /> <asp:Parameter Name="LeaseDateSign" /> <asp:Parameter Name="LeaseDateFrom" /> <asp:Parameter Name="LeaseDateTo" /> <asp:Parameter Name="PerformState" /> <asp:Parameter Name="SafetyContract" /> <asp:Parameter Name="FamilyPlanningContract" /> <asp:Parameter Name="FoodContract" /> <asp:Parameter Name="ContractResponsible" /> <asp:Parameter Name="ContractChange" /> <asp:Parameter Name="ReferencePrice" /> <asp:Parameter Name="ReferencePriceRemarks" /> <asp:Parameter Name="ContractRemarks" /> <asp:Parameter Name="TypeOfPayment" /> <asp:Parameter Name="MonthRent" /> <asp:Parameter Name="RealityYearRent" /> <asp:Parameter Name="SumRent" /> <asp:Parameter Name="LeaseAssureMoney" /> <asp:Parameter Name="RateOfRise" /> <asp:Parameter Name="original_ContractNumber" /> <asp:Parameter Name="original_SumbitNumber" /> <asp:Parameter Name="original_ContractTypeDetail" /> <asp:Parameter Name="original_ContractType" /> <asp:Parameter Name="original_SubjectMatter" /> <asp:Parameter Name="original_City" /> <asp:Parameter Name="original_Road" /> <asp:Parameter Name="original_Address" /> <asp:Parameter Name="original_OppositeSide" /> <asp:Parameter Name="original_ManageProject" /> <asp:Parameter Name="original_LeaseDateSign" /> <asp:Parameter Name="original_LeaseDateFrom" /> <asp:Parameter Name="original_LeaseDateTo" /> <asp:Parameter Name="original_SafetyContract" /> <asp:Parameter Name="original_FamilyPlanningContract" /> <asp:Parameter Name="original_FoodContract" /> <asp:Parameter Name="original_ContractResponsible" /> <asp:Parameter Name="original_ContractChange" /> <asp:Parameter Name="original_ReferencePrice" /> <asp:Parameter Name="original_ReferencePriceRemarks" /> <asp:Parameter Name="original_ContractRemarks" /> <asp:Parameter Name="original_TypeOfPayment" /> <asp:Parameter Name="original_MonthRent" /> <asp:Parameter Name="original_RealityRent" /> <asp:Parameter Name="original_RealityYearRent" /> <asp:Parameter Name="original_SumRent" /> <asp:Parameter Name="original_LeaseAssureMoney" /> <asp:Parameter Name="original_RateOfRise" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="SumbitNumber" /> <asp:Parameter Name="ContractTypeDetail" /> <asp:Parameter Name="ContractType" /> <asp:Parameter Name="SubjectMatter" /> <asp:Parameter Name="SubjectState" /> <asp:Parameter Name="ContractNumber" /> <asp:Parameter Name="City" /> <asp:Parameter Name="Road" /> <asp:Parameter Name="Address" /> <asp:Parameter Name="OppositeSide" /> <asp:Parameter Name="ManageProject" /> <asp:Parameter Name="LeaseDateSign" /> <asp:Parameter Name="LeaseDateFrom" /> <asp:Parameter Name="LeaseDateTo" /> <asp:Parameter Name="PerformState" /> <asp:Parameter Name="SafetyContract" /> <asp:Parameter Name="FamilyPlanningContract" /> <asp:Parameter Name="FoodContract" /> <asp:Parameter Name="ContractResponsible" /> <asp:Parameter Name="ContractChange" /> <asp:Parameter Name="ReferencePrice" /> <asp:Parameter Name="ReferencePriceRemarks" /> <asp:Parameter Name="ContractRemarks" /> <asp:Parameter Name="TypeOfPayment" /> <asp:Parameter Name="MonthRent" /> <asp:Parameter Name="RealityRent" /> <asp:Parameter Name="RealityYearRent" /> <asp:Parameter Name="SumRent" /> <asp:Parameter Name="LeaseAssureMoney" /> <asp:Parameter Name="RateOfRise" /> </InsertParameters> </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource_City" runat="server" ConnectionString="<%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %>" SelectCommand="SELECT DISTINCT [City] FROM [ContractTable]"> </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource_Road" runat="server" ConnectionString="<%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %>" SelectCommand="SELECT DISTINCT [Road] FROM [ContractTable] WHERE ([City] = @City)"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList_City" Name="City" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource_Address" runat="server" ConnectionString="<%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %>" SelectCommand="SELECT DISTINCT [Address] FROM [ContractTable] WHERE (([City] = @City) AND ([Road] = @Road))"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList_City" Name="City" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="DropDownList_Road" Name="Road" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
     
    </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> </asp:Content>
    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
    2011年7月28日 14:07

答案

全部回复

  • Hi:

    这样看代碼挺痛苦的

    您SqlDataSource_Search的UpdateCommand、DeleteCommand写错了

    以下举其中几一例子:

    AND (([SumbitNumber] = @original_SumbitNumber) OR ([SumbitNumber] IS NULL AND @original_SumbitNumber IS NULL))

    这种条件是筛选不到数据的

    要@original_SumbitNumber等於[SumbitNumber]且又要@original_SumbitNumber是NULL,條件永遠都是false

    正确=>AND ([SumbitNumber] = @original_SumbitNumber)

    这样就干净多了, 其他参数都是一样问题,就不累述了


    Shadowと愉快なコード達
    Please correct me if my concept is wrong
    2011年7月28日 15:54
  • 我尝试了!但不行啊!还是谢谢你的答复!
    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
    2011年7月29日 10:41
  • Hi:

    请问您Update和Delete数据表ContractTable的主键栏位是哪个栏位?目前看起来全部都是的样子

    会不会是Where条件写太多的关系?


    Shadowと愉快なコード達
    Please correct me if my concept is wrong
    2011年7月29日 10:57
  • 属性栏中删除出有{original_0},把这个删掉试试!

    2011年7月30日 3:09
  • 感谢您的回复!星期一去单位再调试一下! 另外我发现一个问题:GridView自带的编辑删除功能对数据库原来的数据有用,但我直接在数据库中添加的数据(有些可以为NULL的我没填),就不能使用编辑删除功能。除非我把数据都写完整了!这是怎么回事?该怎么办? 我使用了SQLTOLINQ!!!
    C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
    2011年7月30日 3:34
  • 你好,需要把对应的column填完整,因为GridView需要知道数据的类型和值,然后才能做相应的编辑或删除。

     


    2011年8月2日 6:48
    版主