日期:2014-05-19  浏览次数:20429 次

gridview单击事件的如何响应
想要做这样的功能,点击gridview中的任意行,链接到另外一页
我是这样写的
protected   void   GridView1_RowDataBound(object   sender,   GridViewRowEventArgs   e)
        {
                string   url,href;

                if   (e.Row.RowType   ==   DataControlRowType.DataRow)
                {
                        这里怎么写?
                        e.Row.Attributes.Add( "onclick ",   href);

                }
        }
不知道中间那段怎么写,这个代码可以实现吗

------解决方案--------------------
写你的条件啊.我想不同行转换的页不一样吧
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "onclick ", "window.location.href= 'webform3.aspx ' ");
}
}
------解决方案--------------------
用datagrid可以吧。里面设置一个超级链接的模板列
------解决方案--------------------
如果你每一行都想连到 aa.aspx,并且不需要查询字符串,那么楼上的方法可行,
如果你想连到 aa.aspx,并且需要根据每一行得到不同的查询字符串值,那么需要给gridview创建链接列HypeLinkField,在链接列中设置每一行的查询字符串值