C#在asp.net

时间:2017-04-13 06:40:02

标签: c# asp.net gridview

如何禁用GridView标头? 我没有给他们一个名字,但它仍然显示“colum1”,“colum2”

我已经尝试过:

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

但那不起作用...... 那么如何解决这个问题?

我的代码:

 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);

1 个答案:

答案 0 :(得分:2)

您应该能够在gridview的asp代码中使用标记showHeader = false来禁用标头,如下所示:mappend