Values of hidden columns and columns in the Gridview

Source: Internet
Author: User

To sum up the hidden columns in the Gridview, two methods are described below:
This means that the column in the data Table you get will not bind a value to it, and make sure that your Table contains this column of data. For example, you need to query two columns: name; id, now you only want to display the name, not the id, but when the background code needs to use the id value, you can directly query it and bind the name to a column on the Gridview, set the DataKeyName = "id" of the Gridview, and then directly set the value in the background, for example, to obtain the id value of the first line, you can directly GridView1.DataKeys [1] ["id,
Method 2:
Directly write in the GridView1_RowCreated event: if (e. Row. RowType = DataControlRowType. DataRow |
E. Row. RowType = DataControlRowType. Header)
{
E. Row. Cells [0]. Visible = false; // If id is the first column, set its visibility to false,
}
When the value is set, e. Row. Cells [0] is enough.

Related Article

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.