但是这个grideview 没有checkbox button 只是单击下选中一行,就是获取不到每行的ID,,我也设置 了datakeyNames 为 表里的ID,,我现在就想单击这行,获取ID 我从而可以删除这行数据。 比如我想获取ID的值。我用的datakeyNames 来保存这个ID 页面上只显示 序号 检测项目 检测依据   然后gridview 外面有一个删除的按钮  就是通过这个按钮来来删除,但同时也也传入ID、进来

解决方案 »

  1.   

      protected void gvTestItemList_RowDataBound(object sender, GridViewRowEventArgs e)
            {
               
                if (e.Row.RowType==DataControlRowType.DataRow)
                {
                 
                    e.Row.Attributes.Add("onMouseOver","SetNewColor(this);");
                    e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
                    e.Row.Attributes.Add("ondblclick", "SetNewColor(this);");
                    e.Row.Attributes["style"] = "cursor:pointer";  
                 //这个获取 了所有的ID  不能单击一行获取这一行ID
                    int index =Convert.ToInt32(gvTestItemList.DataKeys[e.Row.RowIndex].Value);
                               }        }