1、在前台添加OnRowDataBound="gvShow_RowDataBound" 事件
<CimesUI:CimesGridView Width="60%" style="margin:0 auto;" ID="gvShow" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvShow_RowDataBound" allowpaging="true" pagesize="30">
2、在后台的gvShow_RowDataBound设置要隐藏的列
protected void gvShow_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { // 隐藏表头的列 e.Row.Cells[3].Visible = false; // 根据索引隐藏列 } else if (e.Row.RowType == DataControlRowType.DataRow) { // 隐藏数据行的列 e.Row.Cells[3].Visible = false; // 根据索引隐藏列 } }
标签:gridview,gvShow,C#,前台,RowDataBound,隐藏,Row From: https://www.cnblogs.com/kelenote/p/18499236