GridView PostBack事件难度很大

时间:2008-12-18 07:58:22

标签: events gridview postback

在RowDataBound OnClick事件处理程序中,当我单击任何行时,它打印'Hi'。但我希望它只在我点击第15行时打印'Hi'。我该如何实现呢?

我的代码:

protected void dtvExDetails_RowDataBound1(object sender, GridViewRowEventArgs e)
{

    if (e.Row.DataItemIndex == -1)
        return;

    e.Row.Attributes.Add("onMouseOver","this.style.cursor='hand';");
    e.Row.Attributes.Add("onclick", this.GetPostBackClientEvent(dtvExDetails, "Select$15"));
}


protected void dtvExDetails_SelectedIndexChanged(object sender, EventArgs e)
{
    Response.Write("hi");
    DataGrid();
}

1 个答案:

答案 0 :(得分:1)

  protected void dtvExDetails_SelectedIndexChanged(object sender, EventArgs e)
    {
            GridViewRow selrow = sender as GridViewRow;

            if(selrow.Count == 15)
                Response.Write("hi");
            DataGrid();
    }