没有重载匹配委托

没有重载匹配委托

这段代码产生了上面的错误,我试图做一些将文件发送到 ftp 服务器的方法

public void btnSend_Click(object sender, GridViewCommandEventArgs e)
{


    msgerror = SP.StrSPBUS_DocClient(Convert.ToInt32(e.CommandArgument.ToString()));

    if (msgerror.Equals("Sucess"))
    {
        String Files = SP.OUTSTR_NMDOCUMENT;
        String Address = SP.OUTSTR_FTPCAM;
        String User = SP.OUTSTR_FTPUSER;
        String Pass = SP.OUTSTR_FTPPASS;

        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Address + "/" + Path.GetFileName(File));
        request.Method = WebRequestMethods.Ftp.UploadFile;
        request.Credentials = new NetworkCredential(User, Pass);
        request.UsePassive = true;
        request.UseBinary = true;
        request.KeepAlive = false;

        var stream = File.OpenRead(Files);
        byte[] buffer = new byte[stream.Length];
        stream.Read(buffer, 0, buffer.Length);
        stream.Close();

        var reqStream = request.GetRequestStream();
        reqStream.Write(buffer, 0, buffer.Length);
        reqStream.Close();
    }
    else
    {
        SP.StrImprimeMessage("Error!");
        return;
    }
}

和文件 .aspx 这是按钮的代码
<tr class="tabelinner">
            <td class="leftcell" valign="middle">

                    <asp:Button ID="btnSrend" runat="server" Text="Send" CssClass="ButtonLink" ValidationGroup="sending"  CommandArgument="Sending" onclick="btnSend_Click"     />
                <br />
            </td>
        </tr>

最佳答案

问题是 GridViewCommandEventArgs 应该只是 EventArgs

public void btnSend_Click(object sender, EventArgs e)

编辑:

我看到在你的代码中你使用了命令参数,所以如果你想使用它,你应该看到 this post

基本上使用 onCommand 而不是 onClick 或将发送者转换为按钮以获取命令参数,例如:
var argument = ((Button)sender).CommandArgument;

关于c# - '' 没有重载匹配委托(delegate) 'System.EventHandler',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19392033/

10-11 23:22