在GridView中为一个按钮加一个事件,如何响应这个事件?谢谢

解决方案 »

  1.   

      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[1].Attributes.Add("class", "text");
                if (GridView1.PageIndex == 0)
                {
                    e.Row.Cells[6].Attributes.Add("onclick", "window.showModalDialog('DetailContentNews.aspx?id=" + GridView1.DataKeys[e.Row.DataItemIndex].Value.ToString() + "','查看详情','dialogWidth:500px;dialogHeight:500px;center:yes;help:no;resizable:no;status:no')");
                }
                else { e.Row.Cells[6].Attributes.Add("onclick", "window.showModalDialog('DetailContentNews.aspx?id=" + GridView1.DataKeys[e.Row.DataItemIndex - 100 * GridView1.PageIndex].Value.ToString() + "','查看详情','dialogWidth:500px;dialogHeight:500px;center:yes;help:no;resizable:no;status:no')"); }
            }
        }上面是响应按钮“查看详细"弹出窗口页面DetailContentNews.aspx。
    这只是一种方式,给gridview的cell绑定Attributes