隐藏列的代码
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false; //隐藏ID列,可以取得该隐藏列的信息
}
}
点选择时取值的代码
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string str = this.GridView1.Rows[e.NewSelectedIndex].Cells[0].Text;
Response.Write(str);
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8688837/viewspace-891166/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8688837/viewspace-891166/