Simultaneous sorting of multiple headers in the GridView

Source: Internet
Author: User

On yueer's blog, I saw the usage of the GridView multi-Table header, but I lost the sorting function of GV. I changed the code and implemented these two functions at the same time, which is very good.

Background code

Protected void GridView1_RowCreated (object sender, GridViewRowEventArgs e)
{
// Create multiple headers
If (e. Row. RowType = DataControlRowType. Header)
{
Int x = 0; // create a variable to insert the cell directly into the header, instead of clearing the original function.
TableCellCollection tcHeader = e. Row. Cells;
// The first column
TcHeader. AddAt (x, new TableHeaderCell ());
TcHeader [x]. Attributes. Add ("colspan", "5"); // cross-Column
// TcHeader [0]. Attributes. Add ("rowspan", "2"); // cross row
TcHeader [x]. Text = "</th> </tr> <tr>"; // input html to wrap multiple headers
X ++;
.....
// Add css attribute adjustment only in the second column
TcHeader [x]. Attributes. Add ("style", "background-color: LightSteelBlue ");
X ++;
}
}

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.