各位大侠,我是用gridview来显示一个文章列表的一些信息,我就是想在点击标题时,能获取该行的内容,以便在另一个内容显示,我是想用rowdatabound来实现的,但不知该怎么写?

解决方案 »

  1.   


        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Cells[0].Attributes.Add("onclick", "show(this)");
                }
             }
      

  2.   

    e.Row.Cells[0].Text
    使用模板列连接其他页面
    <a href='show.aspx?id=<%# Eval("ID") %>' target="_blank"><%# Eval("Title")%></a>
      

  3.   

    e.Row.Cells[0].Text 
    使用模板列连接其他页面 
    <a href='show.aspx?id= <%# Eval("ID") %>' target="_blank"> <%# Eval("Title")%> </a>
      

  4.   

    加模板列,模板列中加按钮,按钮的Text属性绑定到显示的标题列,CommandArgument属性绑定到关键字列,这样在其点击事件中通过e.CommandArgument就可以得到关键字,剩下的就好办了。
    第二个方法更简单,加入“选择”(就是ShowSelect设置为true),然后把选择列的文本显示为标题就可以了,点了某个标题就会触发SelectedIndexChanged事件,通过SelectedItem之类的就可以处理,呵呵