Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a gridview which is field from database.so how can hide column in gridview
Posted

Hi,

This article can help you:
Show / Hide GridView Columns in ASP.NET[^]
 
Share this answer
 
hi,
set the visible property of that particular column to be false.
 
Share this answer
 
Comments
Member 9334390 19-Oct-12 12:12pm    
but in grid view all column are bounded field
If you are working with
1. AutoGenerate Columns then
GrdCustomer.RowDataBound += new System.Web.UI.WebControls.GridViewRowEventHandler(GrdCustomer_RowDataBound);
.
.
.
void GrdCustomer_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
   e.Row.Cells[0].Visible = false;
}

2. Bound Fields then
<asp:BoundField DataField="CustomerName" Visible="false" />

3.Template Field
XML
<asp:TemplateField HeaderText="Customer Name" Visible="false">
    <ItemTemplate>
        <asp:Label Text='<%# Eval("CustomerName") %>' runat="server" ID="LblCusomerName" />
    </ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
set visible for that column false..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900