我照gridview中加入一个按钮列,并且设置为可见,需要在html中直接加入代码 
<asp:CommandField ShowSelectButton = "True" HeaderText="点击选择" /> 
如果不加此列Visible=false,须在<%@ Page %>中加上EnableEventValidation="false" 才不会报错 
后台代码中加入下面 
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        //这是个测试,在一个文本框里显示你所点击表格中一行中的一个列值 
        this.TextBox1.Text = GridView1.SelectedRow.Cells[3].Text; 
    } 
       
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
        int i; 
        for (i = 0; i <= GridView1.Rows.Count; i++) 
        { 
            //首先判断是否是数据行 
            if (e.Row.RowType == DataControlRowType.DataRow) 
            { 
                //当鼠标停留时更改背景色 
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'"); 
                //当鼠标移开时还原背景色 
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); 
                //单击行的任意列会自动选中此行,加在RowCreated事件中也可以 
                e.Row.Attributes.Add("onclick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')"); 
            } 
        } 
    }本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jiang_ideal/archive/2009/02/13/3885578.aspx
这些写,可是实现不了啊 

解决方案 »

  1.   

    那就再你的单击事件中获取你需要的值 并将这个值传到其他页面阿!至于传值么。就是在你的单击事件中show一个窗体阿
      

  2.   

    不太明白你说的
    e.Row.Attributes.Add("onclick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')"); 
    这个不是给行添加
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 事件吗,但是我现在点击行,不走这个事件啊