2018年3月21日 星期三

aspnet Hiding column in GridView 方法

<style type="text/css">
 .hide {display:none;}
</style>

<asp:GridView ....
<Columns>
            <asp:BoundField DataField="fieldFromDB" HeaderText="Some text" SortExpression="fieldFromDB">
             <HeaderStyle CssClass="hide" />
             <ItemStyle CssClass="hide" />
            </asp:BoundField>
</Columns>
</asp:GridView>


Protected Sub GridView2_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.Cells[index].Visible = false
        End If
    End Sub

沒有留言:

張貼留言