如果要在GridView 控件中隐藏不必要的列,使用<asp:BoundField DataField="sex" Visible="false"/>后 你就无法取得这列的值了.
解决办法: OnRowDataBound="GridView1_RowDataBound"
    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[4].Visible = false;
        }
    }