Reputation: 11
I am doing something like this dt.Columns.Add("SomeCoumnName"); But I don't want to display this column name after binding it to the gridview. Just want to show a blank header for particular column.
Upvotes: 1
Views: 643
Reputation: 685
Set AutoGenerateColumns="false" in Gridview and create custom header like in given sample. If you don't want to show header for a particular column then set HeaderText="" in <asp:BoundField ...>
<asp:GridView ID="grdSearch" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="County"
DataField="Prop_County" SortExpression="Prop_County" ItemStyle-Width="70px" HeaderStyle-Height="25px">
</asp:BoundField>
<asp:BoundField HeaderText="Sale Date"
DataField="Prop_Sale_Date" ItemStyle-Width="55px"></asp:BoundField>
<asp:BoundField HeaderText="Sale Time"
DataField="Prop_Sale_Time" ItemStyle-Width="55px"></asp:BoundField>
<asp:BoundField HeaderText="Bid Amount"
DataField="Prop_Bid_Amnt" ItemStyle-Width="100px"></asp:BoundField>
</Columns>
</asp:GridView>
Upvotes: 2