Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide gridview column header

I have a gridview that is populated from a sqldatasource with ajax, which is fired from a radcombox drop down. The below does not work because technically the gridview hasn't loaded. Is there an easy work around?

Protected Sub RadComboBox1_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox1.SelectedIndexChanged
    GridView1.HeaderRow.Cells(1).Visible = False
End Sub
like image 725
user3749447 Avatar asked Jul 03 '14 14:07

user3749447


People also ask

How to hide column header in GridView in c#?

To hide the column headers Set the DataGridView. ColumnHeadersVisible property to false .

How to display a datagridview without column headers?

Sometimes you will want to display a DataGridView without column headers. In the DataGridView control, the ColumnHeadersVisible property value determines whether the column headers are displayed. Set the DataGridView.ColumnHeadersVisible property to false. A DataGridView control named dataGridView1.

How to hide columns in the Windows Forms datagridview?

In the DataGridView control, the Visible property value of a column determines whether that column is displayed. There is support for this task in Visual Studio. Also see How to: Hide Columns in the Windows Forms DataGridView Control Using the Designer. Set the DataGridViewColumn.Visible property to false.

Which datagridview control contains a column named CUSTOMERID?

A DataGridView control named dataGridView1 that contains a column named CustomerID. References to the System and System.Windows.Forms assemblies. Basic Column, Row, and Cell Features in the Windows Forms DataGridView Control

How to hide a column that is automatically generated during databindingcomplete?

Set the DataGridViewColumn.Visible property to false. To hide a CustomerID column that is automatically generated during data binding, place the following code example in a DataBindingComplete event handler. A DataGridView control named dataGridView1 that contains a column named CustomerID.


2 Answers

<asp:GridView ID="GridView1" runat="server" ShowHeader="False">
        </asp:GridView>

showheader=false on the aspx page

like image 125
user3786581 Avatar answered Sep 17 '22 00:09

user3786581


Just hide the cell after the entire GridView is bound in the DataBound event:

Protected Sub GridView1_DataBound(sender As Object, e As EventArgs)  
    GridView1.HeaderRow.Cells(1).Visible = False
End Sub

<asp:GridView ID="GridView1" runat="server" OnDataBound="GridView1_DataBound">

Just know that this only hides the contents of the header cell, not the entire column.

like image 43
j.f. Avatar answered Sep 19 '22 00:09

j.f.