No 33 · 实现单击表格行打开另一页并传递参数

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 );
            e.Row.Attributes.Add("onclick", "window.open('Default2.aspx?title=" + url + "');");

        }
    }

你可能感兴趣的:(No 33 · 实现单击表格行打开另一页并传递参数)