24
Jul/09
0

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)

?View Code CSHARP
1
2
3
4
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
}
Print This Post
(5 votes, average: 5.00 out of 5)
Loading ... Loading ...
1,575 views
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


No trackbacks yet.