2

How can i disable the GridView Headers? I didn't give them a Name but it still shows "colum1", "colum2"

I already tried:

GridView.ShowHeader = false; GridView.HeaderRow.Enable = false;

But that didn't work... So how to solve this problem?

My Code:

 GridView gw = new GridView();

 gw.DataSource = tblDetails;
 gw.DataBind();
 gw.CssClass = tblDetailsCssClass;
 gw.RowStyle.Height = 50;           

 panelMain.Controls.Add(gw);

CssClass:

.Bilddb-tblDetails
    {
        color:black;
        font-size:2em;
        margin: 0 auto; 
        margin-top:20px;   
        display:block;
        width:100%
    }

tblDetails:

DataTable tblDetails = new DataTable();
        DataColumn colum;
        DataRow row;

        colum = new DataColumn();
        colum.DataType = Type.GetType("System.String");            
        tblDetails.Columns.Add(colum);

        colum = new DataColumn();
        colum.DataType = Type.GetType("System.String");            
        tblDetails.Columns.Add(colum);


        row = tblDetails.NewRow();
        row[0] = "Title:";
        row[1] = item.Title;
        tblDetails.Rows.Add(row);

        row = tblDetails.NewRow();
        row[0] = "Botanical Name:";
        row[1] = item.BotanicalName;
        tblDetails.Rows.Add(row);
7
  • 1
    asp.net or winform ? Commented Apr 13, 2017 at 6:41
  • Oh i mean in asp.net Commented Apr 13, 2017 at 6:45
  • Can you show us the definition of the GridView control? Commented Apr 13, 2017 at 6:47
  • Yes of course - I added it Commented Apr 13, 2017 at 6:51
  • And what about the structure of object tblDetails? Commented Apr 13, 2017 at 6:54

1 Answer 1

2

You should be able to disable the header by using the tag showHeader=false in asp code for the gridview like so: <asp:Gridview runat=server showHeader=false etc>

Sign up to request clarification or add additional context in comments.

2 Comments

Oh nice that worked. But why doesnt that work in the cs code?
Because it is done by programatic way, instead of setting the tags, I had the same problem about three weeks ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.