Background event Functions
Protected Void Gvradar_rowcreated ( Object Sender, gridviewroweventargs E)
{
If (E. Row. rowtype = Datacontrolrowtype. header)
{
Tablecellcollection TCL = E. Row. cells;
// Clear automatically generated Headers
TCL. Clear ();
// Add a new Header
TCL. Add ( New Tableheadercell ());
TCL [ 0 ]. Rowspan = 2 ; // Merge rows
TCL [ 0 ]. Text = " Station No. " ;
Label L1 = New Label ();
L1.text = " Station No. " ;
// Because of the custom header, the sorting function originally implemented in the system becomes invalid.
// The following statements can be used to add controls to the table header and perform sorting by yourself.
TCL [ 0 ]. Controls. Add (L1 );
TCL. Add ( New Tableheadercell ());
TCL [ 1 ]. Rowspan = 2 ; // Merge Columns
TCL [ 1 ]. Text = " Station Name " ;
TCL. Add ( New Tableheadercell ());
TCL [ 2 ]. Rowspan = 2 ; // Merge rows
TCL [ 2 ]. Text = " Report times " ;
TCL. Add ( New Tableheadercell ());
TCL [ 3 ]. Columnspan = 2 ; // Merge Columns
TCL [ 3 ]. Text = " Report " ;
TCL. Add ( New Tableheadercell ());
TCL [ 4 ]. Columnspan = 2 ;
TCL [ 4 ]. Text = " Limit report " ;
TCL. Add ( New Tableheadercell ());
TCL [ 5 ]. Columnspan = 2 ;
// This section focuses on converting TCL [5] to <TH> Title 5 </Th> In the generated HTML.
// Therefore, HTML tags are injected according to this principle, which is similar to SQL injection attacks.
// TCL [5]. TEXT = "Title 5 </Th> </tr> <TH> Title 2-1 </Th> <TH> Title 2-2 </Th> <th> Title 4-1 </Th> <TH> Title 4-2 </Th> <TH> Title 4-3 <TH> Title 6 </Th> <TH> title 7 </Th> <TH> Title 8 <TH> Title 9 </Th> ";
TCL [ 5 ]. Text = " False Positive </Th> </tr> <TH> site count </Th> <TH> Percentage </Th> <TH> site count </Th> <TH> Percentage </Th> <TH> count </Th> <TH> Percentage " ;
}
Foreground gridview control!
< Div >
< ASP: gridview ID = "Gv_radar" Runat = "Server" Cssclass = "Gridviewborder" Autogeneratecolumns = "False" Onrowcreated = "Gvradar_rowcreated" >
<% -- <Headerstyle cssclass="Gridviewheader"/> -- %>
< Rowstyle Cssclass = "Gridviewrow" />
< Columns >
< ASP: boundfield Headertext = "Station number" Datafield = "Station number" />
< ASP: boundfield Headertext = "Station name" Datafield = "Station name" />
< ASP: boundfield Headertext = "" Datafield = "" />
< ASP: boundfield Headertext = "Arrival Time" Datafield = "Arrival Time" />
< ASP: boundfield Headertext = "Percentage to report" Datafield = "Percentage to report" />
< ASP: boundfield Headertext = "Delayed Report times" Datafield = "Delayed Report times" />
< ASP: boundfield Headertext = "Late percentage" Datafield = "Late percentage" />
< ASP: boundfield Headertext = "Error reported" Datafield = "Error reported" />
< ASP: boundfield Headertext = "Percentage of missing reports" Datafield = "Percentage of missing reports" />
</ Columns >
< Emptydatatemplate >
< Span Style = "Color: red; text-align: center ;" > No data </ Span >
</ Emptydatatemplate >
</ ASP: gridview >
</ Div >