如果要在GridView 控件中隐藏不必要的列,使用visible="false"后 你就无法取得这列的值了.
解决问题的方法很简单:
--------------------------------------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//隐藏不必要的列
if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
{
e.Row.Cells[0].Visible=false;
e.Row.Cells[3].Visible=false;
}
}
--------------------------------------------------
这种解决方法还是比较简单的,以前也遇到这种问题,只是没有写出来,现在写出来以供大家查询用。