Asp.net gridView不显示行标题

时间:2018-01-26 12:01:43

标签: c# asp.net

我有这个问题,         当表为空时,GridView不显示行标题         我使用.net框架4和Internet Explorer,你能帮助我吗?         这是代码:

 this is code   
     private void loadTCOR27()
             {
                 SqlDataAdapter adapter = new SqlDataAdapter();
                 DataSet ds = new DataSet();
                 try
                 {
                     string sql = null;
                     gridViewTCOR27.Visible = true;
                     table1.Visible = false;
                     string connectionString = SestanteWeb.Global.rCRVigServer.leggiStringaConnessioneSicurezzaSqlClient();
                     sql = "select * FROM [PUMA2_FINANZIARIAFAMILIARE].[dbo].[TCOR27]";
                     SqlConnection connection = new SqlConnection(connectionString);
                     connection.Open();
                     SqlCommand command = new SqlCommand(sql, connection);
                     adapter.SelectCommand = command;
                     adapter.Fill(ds);
                     adapter.Dispose();
                     command.Dispose();
                     connection.Close();
                     // gridView1.DataSource = ds.Tables[0];
                     gridViewTCOR27.DataSource = ds.Tables[0];
                     gridViewTCOR27.DataBind();

                 }
                 catch (Exception ex)
                 {


                 }
                 finally
                 {
                     adapter.Dispose();

                 }
             }

1 个答案:

答案 0 :(得分:2)

在Gridview声明中将属性ShowHeaderWhenEmpty设置为true。可能它会帮助你。

以下是对此属性的引用。 Ref