No 32 · 实现双击表格行超级链接到另一页并传递参数

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //如果当前项不为空
        if (e.Row.RowIndex != -1)
        {
            //取得当前项的索引值加1,因为项的索引值是从0开始的
            int orderID = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = orderID.ToString();
        }
        {
            //点击表格打开
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string url = Server.UrlEncode(e.Row.Cells[1].Text.ToString());
                e.Row.Attributes.Add("ondblclick", "location.href='Default2.aspx?title=" + url + "'");
              
            }
        }
    }

你可能感兴趣的:(No 32 · 实现双击表格行超级链接到另一页并传递参数)