none
GridVeiw 删除记录出错:至一个参数没有被指定 RRS feed

  • 问题

  • 问题:GridVeiw 删除记录出错:至一个参数没有被指定.
    GridView可以执行更新操作.
    如果在ads_wod的SelectQuery中只使用表WOD的字段,可以正常删除记录和更新记录,
    但是加入表Material中的字段的后,就只能更新记录,不能删除记录.


    test1.apsx.cs代码:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;
    
    public partial class test1 : System.Web.UI.Page
    {
        protected int CurrentPage;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack) 
            {
             
    
            }
    
        }
    
    
    
        protected void ImageButton2_Click1(object sender, ImageClickEventArgs e)
        {
            if (tb_wono.Text != string.Empty) 
            {
                Session["woid"] = tb_wono.Text;
            }
    
        }
    }
    


    test1.aspx代码:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test1.aspx.cs" Inherits="test1" %>
    
    
    <%@ Register Assembly="WebControl" Namespace="Voodooer.Soft.WebControl" TagPrefix="cc1" %>
    
    <!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>
        <script language="javascript" src="jscript.js"></script>
        <script type="text/javascript">
    function findwo()
    {
        var v = new Array(9);
        v = showModalDialog("wolist.aspx?random="+Math.random(),v,"status:yes;Help:no;resizable:yes;DialogWidth:810px;DialogHeight:600px");
        document.getElementById('<%=this.tb_wono.ClientID  %>').value=v[0];
        document.getElementById('<%=this.ImageButton2.ClientID  %>').focus();
    
    }
         function testt()
         {
         
           //document.getElementById('').value="a;sdlfalsf";
           return true;
         }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <cc1:_Title_Small ID="_Title_Small15" runat="server" Font-Size="Small">工单编号:</cc1:_Title_Small><asp:TextBox
                ID="tb_wono" runat="server" Font-Size="Small" Height="15px"></asp:TextBox><asp:ImageButton
                    ID="ImageButton2" runat="server" ImageUrl="~/img/Find_16.ICO" OnClick="ImageButton2_Click1"
                    OnClientClick="return findwo()" />&nbsp;
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <cc1:_GridView ID="_GridView1" runat="server" AutoGenerateColumns="False" CurrentPage="0"
                                DataSourceID="ads_wod" Font-Size="Small" ForeColor="#333333" PagingStyle="None">
                                <Columns>
                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                    <asp:BoundField DataField="NO" HeaderText="NO" SortExpression="NO" />
                                    <asp:BoundField DataField="Line" HeaderText="Line" SortExpression="Line" />
                                    <asp:BoundField DataField="MID" HeaderText="MID" SortExpression="MID" />
                                    <asp:BoundField DataField="RAmount" HeaderText="RAmount" SortExpression="RAmount" />
                                    <asp:BoundField DataField="CAmount" HeaderText="CAmount" SortExpression="CAmount" />
                                    <asp:BoundField DataField="FAmount" HeaderText="FAmount" SortExpression="FAmount" />
                                    <asp:BoundField DataField="SAmount" HeaderText="SAmount" SortExpression="SAmount" />
                                    <asp:BoundField DataField="Expr1" HeaderText="Expr1" SortExpression="Expr1" />
                                    <asp:BoundField DataField="model" HeaderText="model" SortExpression="model" />
                                    <asp:BoundField DataField="unit" HeaderText="unit" SortExpression="unit" />
                                </Columns>
                                <RowStyle BackColor="#F1F4F8" Wrap="False" />
                                <SelectedRowStyle BackColor="#CFE4F9" />
                                <HeaderStyle BackColor="#A4CEF9" Font-Size="Small" ForeColor="Black" Wrap="False" />
                                <AlternatingRowStyle BackColor="White" />
                            </cc1:_GridView>
                            <asp:LinkButton ID="LinkButton1" runat="server" Font-Size="Small" 
                                OnClientClick="return findmid();">新增一行</asp:LinkButton>
                            <input id="h_mid" runat="server" style="width: 21px" type="hidden" /><asp:AccessDataSource
                                ID="ads_wod" runat="server" CancelSelectOnNullParameter="False" DataFile="~/App_Data/db.mdb"
                                DeleteCommand="DELETE FROM WOD WHERE ([NO] = ?) AND ([MID] = ?)" InsertCommand="INSERT INTO [WOD] ([NO], [MID], [Line], [RAmount], [CAmount], [FAmount], [SAmount]) VALUES (?, ?, ?, ?, ?, ?, ?)"
                                 SelectCommand="SELECT WOD.[NO], WOD.Line, WOD.MID, WOD.RAmount, WOD.CAmount, WOD.FAmount, WOD.SAmount, material.[no] AS Expr1, material.model, material.unit FROM (WOD INNER JOIN material ON WOD.MID = material.ID) WHERE (WOD.[NO] = ?) ORDER BY WOD.Line"
                                UpdateCommand="UPDATE [WOD] SET [Line] = ?, [RAmount] = ?, [CAmount] = ?, [FAmount] = ?, [SAmount] = ? WHERE [NO] = ? AND [MID] = ?">
                                <UpdateParameters>
                                    <asp:Parameter Name="Line" Type="String" />
                                    <asp:Parameter Name="RAmount" Type="Double" />
                                    <asp:Parameter Name="CAmount" Type="Double" />
                                    <asp:Parameter Name="FAmount" Type="Double" />
                                    <asp:Parameter Name="SAmount" Type="Double" />
                                    <asp:SessionParameter Name="NO" SessionField="woid" Type="Int32" />
                                    <asp:Parameter Name="MID" Type="Int32" />
                                </UpdateParameters>
                                <SelectParameters>
                                    <asp:SessionParameter Name="no" SessionField="woid" />
                                </SelectParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="NO" Type="Int32" />
                                    <asp:Parameter Name="MID" Type="Int32" />
                                    <asp:Parameter Name="Line" Type="String" />
                                    <asp:Parameter Name="RAmount" Type="Double" />
                                    <asp:Parameter Name="CAmount" Type="Double" />
                                    <asp:Parameter Name="FAmount" Type="Double" />
                                    <asp:Parameter Name="SAmount" Type="Double" />
                                </InsertParameters>
                                <DeleteParameters>
                                    <asp:SessionParameter Name="NO" SessionField="woid" />
                                    <asp:Parameter Name="MID" />
                                </DeleteParameters>
                            </asp:AccessDataSource>
                        </ContentTemplate>
                    </asp:UpdatePanel>
        </form>
    </body>
    </html>
    



    QQ:58413403 Email:voodooer@126.com
    2010年1月8日 0:41

答案