Modify the program in the group row section of the msdn ASP. NET gridview dataset Sample Set

Source: Internet
Author: User

 

This may be caused by typographical layout. Some programs published in the ASP. NET gridview dataset on msdn in the group row section include batch layout,

Specifically, this list is used to list the correct program category (mainly the generic category data of the generic list) <,> operator, may have been missed during formatting ).

 

Group row program running

Private void preparegroup ()
{
Int lastsupid =-1;
Gridviewrow currentrow = NULL;
List <gridviewrow> Tempmodifyrows = new list <gridviewrow> ();
Foreach (gridviewrow row in gridview1.rows)
{
If (row. rowtype = datacontrolrowtype. datarow)
{
If (currentrow = NULL)
{
Currentrow = row;
Int. tryparse (row. cells [2]. Text, out lastsupid );
Continue;
}

Int currsupid =-1;
If (Int. tryparse (row. cells [2]. Text, out currsupid ))
{
If (lastsupid! = Currsupid)
{
Currentrow. cells [2]. attributes ["rowspan"] = (tempmodifyrows. Count + 1). tostring ();
Currentrow. cells [2]. attributes ["valign"] = "center ";
Foreach (gridviewrow row2 in tempmodifyrows)
Row2.cells. removeat (2 );
Lastsupid = currsupid;
Tempmodifyrows. Clear ();
Currentrow = row;
Lastsupid = currsupid;
}
Else
Tempmodifyrows. Add (ROW );
}
}
}

If (tempmodifyrows. Count> 0)
{
Currentrow. cells [2]. attributes ["rowspan"] = (tempmodifyrows. Count + 1). tostring ();
Currentrow. cells [2]. attributes ["valign"] = "center ";
Foreach (gridviewrow row2 in tempmodifyrows)
Row2.cells. removeat (2 );
}
}

Protected void gridviewincluprerender (Object sender, eventargs E)
{
Preparegroup ();
}

 

Sorry for the problem that caused everyone else.

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.