0

GridViewTranstoCon在主 gridview 中有一个 gridview GridViewTtransmittals。现在因为GridViewTranstoCon_RowDeleting我已经编写了下面的代码,但是它失败了。

protected void GridViewTranstoCon_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    GridView TranstoCon = GridViewTtransmittals.FindControl("GridViewTranstoCon") as GridView;


    OnDeleteTtransmittaltocon(Convert.ToInt32(TranstoCon.DataKeys[e.RowIndex].Value));
        }


private void OnDeleteTtransmittaltocon(int transmittoconid,int transid)
{
    if (DeleteTransmittaltocon != null)
    {
        DeleteTransmittaltocon(this, new tbltranstoconEventArgs { TransmittoconID = transmittoconid, TransID = transid });
      //  DeleteTransmittaltocon(this, new tbltranstoconEventArgs { TransmittoconID = transmittoconid });
    }
}

我的事件处理程序如下所示,我不知道如何添加另一个参数。

public class tbltransmittalNoEventArgs : EventArgs
{
    public int TransID { get; set; }
}

public class tbltranstoconEventArgs : EventArgs
{
    public int TransmittoconID { get; set; }
    public int TransID { get; set; }

}

public event EventHandler<tbltranstoconEventArgs> DeleteTransmittaltocon;

我能做些什么?

4

1 回答 1

0

试试这个,发件人应该是被点击的GridView

protected void GridViewTranstoCon_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    //Put a breakpoint after this line, what is value of Id, TranstoCon
    GridView TranstoCon = sender as GridView;
    int Id = Convert.ToInt32(TranstoCon.DataKeys[e.RowIndex].Value);

    //Also step into this and see what it's doing
    OnDeleteTtransmittaltocon(Id);

}
于 2012-10-27T08:47:45.020 回答