回 帖 发 新 帖 刷新版面

主题:“DataGrid_UpdateCommand”的重载均与委托“System.Web.UI.WebC

编译错误 
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 

编译器错误信息: CS0123: “DataGrid_UpdateCommand”的重载均与委托“System.Web.UI.WebControls.GridViewUpdatedEventHandler”不匹配

源错误:

 

行 12:     <center>
行 13:     <b>演示 EditCommandColumn</b>
行 14:         <asp:GridView ID="score" runat="server" HeaderStyle-BackColor="#aaaadd" AlternatingRowStyle-BackColor="#eeeeee" AutoGenerateColumns="false" OnRowCommand="DataGrid_EditCommand" OnRowUpdated="DataGrid_UpdateCommand" OnRowCancelingEdit="DataGrid_CancelCommand">
行 15:         <Columns>
行 16:             <asp:CommandField HeaderText="操作区" EditText="编辑" UpdateText="更新" CancelText="取消" ButtonType="button" />
 

源文件: e:\ASP.NET\Samples\DataGridEditCommandColumn.aspx    行: 14 

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

下面是相关代码:

    //处理Update命令
    public void DataGrid_UpdateCommand(object sender, GridViewCommandEventArgs e) { 
        //更新数据库中的信息
        int index = Convert.ToInt32(e.CommandArgument);
        GridViewRow row = score.Rows[index];
        string strName = row.Cells[1].Text;
        int intChinese = Int32.Parse(((TextBox)row.Cells[2].Controls[0]).Text);
        int intMath = Int32.Parse(((TextBox)row.Cells[3].Controls[0]).Text);
        int intEnglish = Int32.Parse(((TextBox)row.Cells[4].Controls[0]).Text);

        //string strName = e.Item.Cells[1].Text;
        //int intChinese = Int32.Parse(((TextBox)e.Item.Cells[2].Controls[0]).Text);
        //int intMath = Int32.Parse(((TextBox)e.Item.Cells[3].Controls[0]).Text);
        //int intEnglish = Int32.Parse(((TextBox)e.Item.Cells[4].Controls[0]).Text);

        //更新数据库中的数据
        string strUpdate="update score set Chinese="+ intChinese +",Math="+ intMath +",English="+ intEnglish +" where Name='"+ strName +"'";
        OleDbCommand MyComm = new OleDbCommand(strUpdate, MyConn);
        MyComm.ExecuteNonQuery();

        score.EditIndex = -1;
        BindGridView();
=============================================================================================
页面上的代码是:

        <asp:GridView ID="score" runat="server" HeaderStyle-BackColor="#aaaadd" AlternatingRowStyle-BackColor="#eeeeee" AutoGenerateColumns="false" OnRowCommand="DataGrid_EditCommand" OnRowUpdated="DataGrid_UpdateCommand" OnRowCancelingEdit="DataGrid_CancelCommand">
        <Columns>
            <asp:CommandField HeaderText="操作区" EditText="编辑" UpdateText="更新" CancelText="取消" ButtonType="button" />
            <asp:BoundField HeaderText="姓名" DataField="Name" />
            <asp:BoundField HeaderText="语文" DataField="Chinese" />
            <asp:BoundField HeaderText="数学" DataField="Math" />
            <asp:BoundField HeaderText="英语" DataField="English" />
        </Columns>
        </asp:GridView>

回复列表 (共2个回复)

沙发

难道没有一个人知道吗?

板凳

public delegate void DataGridCommandEventHandler (
    Object source,
    DataGridCommandEventArgs e
)


这是来自MSDN的,你注意看看你的是使用了GridViewCommandEventArgs

我来回复

您尚未登录,请登录后再回复。点此登录或注册