protected voidGridview1_rowcreated (Objectsender, GridViewRowEventArgs e) { Switch(e.row.rowtype) { CaseDatacontrolrowtype.header://first Row table headerTablecellcollection Tcheader =E.row.cells; Tcheader.clear (); Tcheader.add (NewTableheadercell ()); tcheader[0]. Attributes.Add ("rowspan","3");//Cross Rowtcheader[0]. Attributes.Add ("bgcolor"," White"); tcheader[0]. Text =""; Tcheader.add (NewTableheadercell ()); //Tcheader[1]. Attributes.Add ("bgcolor", "Red");tcheader[1]. Attributes.Add ("colspan","6");//Cross-columntcheader[1]. Text ="All information"; //second row table headerTcheader.add (NewTableheadercell ()); tcheader[2]. Attributes.Add ("bgcolor","Darkseagreen"); tcheader[2]. Text ="ID Number"; Tcheader.add (NewTableheadercell ()); tcheader[3]. Attributes.Add ("bgcolor","Lightsteelblue"); tcheader[3]. Attributes.Add ("colspan","2"); tcheader[3]. Text ="Basic Information"; Tcheader.add (NewTableheadercell ()); tcheader[4]. Attributes.Add ("bgcolor","Darkseagreen"); tcheader[4]. Text ="Welfare"; Tcheader.add (NewTableheadercell ()); tcheader[5]. Attributes.Add ("bgcolor","Lightsteelblue"); tcheader[5]. Attributes.Add ("colspan","2"); tcheader[5]. Text ="Contact Information"; //third Row table headerTcheader.add (NewTableheadercell ()); tcheader[6]. Attributes.Add ("bgcolor","Khaki"); tcheader[6]. Text ="ID Number"; Tcheader.add (NewTableheadercell ()); tcheader[7]. Attributes.Add ("bgcolor","Khaki"); tcheader[7]. Text ="name"; Tcheader.add (NewTableheadercell ()); tcheader[8]. Attributes.Add ("bgcolor","Khaki"); tcheader[8]. Text ="Date of birth"; Tcheader.add (NewTableheadercell ()); tcheader[9]. Attributes.Add ("bgcolor","Khaki"); tcheader[9]. Text ="Salary"; Tcheader.add (NewTableheadercell ()); tcheader[Ten]. Attributes.Add ("bgcolor","Khaki"); tcheader[Ten]. Text ="Home Address"; Tcheader.add (NewTableheadercell ()); tcheader[ One]. Attributes.Add ("bgcolor","Khaki"); tcheader[ One]. Text ="Postal Code"; Break; } }
GridView merging headers, multiple headers (RPM)