Solution to do not display the table header in the left-side record of the gridview [Ominous author]

Source: Internet
Author: User

In the DataGrid, We can bind a dataset or able that contains an empty record to the DataGrid. In this way, the DataGrid displays the field definitions in the data source in the form of a table header.

In the gridview control, it is not displayed if dataset or able is an empty record. The table header is not displayed in the gridview.
It can only be implemented through a work und, with a little trouble:

Public void buildnorecords (gridview, dataset DS)

{

If (Ds. Tables [0]. Rows. Count = 0)

{

DS. Tables [0]. Rows. Add (Ds. Tables [0]. newrow ());

Gridview. datasource = Ds;

Gridview. databind ();

Int columncount = gridview. Rows [0]. cells. count;

Gridview. Rows [0]. cells. Clear ();

Gridview. Rows [0]. cells. Add (New tablecell ());

Gridview. Rows [0]. cells [0]. columnspan = columncount;

Gridview. Rows [0]. cells [0]. Text = "no records found .";

}

Else

{

Gridview. datasource = Ds;

Gridview. databind ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.