asp.net get the value of the GridView hidden columns _ Practical Tips

Source: Internet
Author: User
Write the following code in the RowCreated event of the GridView:
Copy Code code as follows:

void Gridview1_rowcreated (object sender, GridViewRowEventArgs e)
{
if (E.row.rowtype = = Datacontrolrowtype.datarow | |
E.row.rowtype = = Datacontrolrowtype.header)
{
Hide 1th Column
E.row.cells[0]. Visible = false;
You can hide more columns as needed
}
}

Because the RowCreated event (hidden) occurs at the time of the binding, so that the data is bound to the column and the column is hidden, the value of the hidden column can be accessed.
Copy Code code as follows:

protected void Gvunit_rowdatabound (object sender, GridViewRowEventArgs e)
{
if (E.row.rowtype = = Datacontrolrowtype.datarow)
{
Get the value of a hidden column
if (e.row.cells[1). Text = "xxx")
{
Todo
}
}
}

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.