【问题标题】:Difficulty with GridView PostBack EventsGridView PostBack 事件的困难
【发布时间】:2008-12-18 07:58:22
【问题描述】:

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

我的代码:

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();
}

【问题讨论】:

    标签: events gridview postback


    【解决方案1】:
      protected void dtvExDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
                GridViewRow selrow = sender as GridViewRow;
    
                if(selrow.Count == 15)
                    Response.Write("hi");
                DataGrid();
        }
    

    【讨论】:

    • 谢谢,但最好使用它...它工作正常... if (e.Row.DataItemIndex == 14) { e.Row.Attributes.Add("onclick", this.GetPostBackClientEvent( dtvExDetails, "选择 $15")); }
    猜你喜欢
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 2012-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-16
    • 2017-04-11
    相关资源
    最近更新 更多