24
Jul/090
Jul/090
Hide GridView column at runtime
To hide a column at runtime you can use to the GridView’s RowDataBound event and set the Visible property to false.
ASP Code (Default.aspx)
1 2 3 4 5 6 | <asp:GridView ID="GridView1" runat="server" BorderColor="#666666" BorderStyle="Solid" BorderWidth="1px" OnRowDataBound="GridView1_RowDataBound"> <HeaderStyle BackColor="#999999" Font-Bold="False" Font-Overline="False" Font-Underline="False" ForeColor="Black" HorizontalAlign="Center" /> <AlternatingRowStyle BackColor="#E8E8E8" /> </asp:GridView> |
C# Code (Default.aspx.cs)
1 2 3 4 | protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; } |
1,575 views
