如何删除嵌套gridview的gridview行

时间:2012-10-27 05:21:27

标签: asp.net

我在主网格视图GridViewTranstoCon中有一个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;

我该怎么办?

1 个答案:

答案 0 :(得分: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);

}