日期:2014-05-18  浏览次数:20423 次

!!!!!!!!!!!!!!!我刚工作大家帮帮我!!!!!关于gridview问题
protected   void   GridView1_DataBound(object   sender,   EventArgs   e)
        {
               
                  for(int   i=0;   i <this.GridView1.Rows.Count;   i++)
                {
                        if   (this.GridView1.Rows[i].Cells[3].ForeColor.ToString()   ==   Color.LimeGreen.ToString())
                        {
                                ((Label)this.GridView1.Rows[i].Cells[3].FindControl( "lbldu ")).Attributes.Add( "onclick ",   "window.open( 'bj.aspx ', '详细信息 ', 'height=500,width=900,toolbar=0,menubar=0,scrollbars=0 ') ");
                        }
                }
               
        }

我在rowdatabound绑定了一个鼠标点击事件用于传值,可是我怎样通过这个点击事件获得所点击的行的索引或者主键呢?

请教各位大侠

------解决方案--------------------
同时你再写一个鼠标选择事件
this.GridView.DataKeys[...]取主键贝
------解决方案--------------------
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "OnClick ", "ClickEvent( ' " + e.Row.Cells[6].Text + " ');
}