SQL Server database version
<%@ Page language=" c#" Autoeventwireup="true"%> <script runat="server"> public int trapezoidindex = 1; int lastnumer = 0; protected void Page_Load (object sender, EventArgs e) {string ConnectionString = " Persist Security Info=false; User Id=sa; Password=;initial Catalog=book; Server=.; "; System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection (ConnectionString); cn. Open (); String sql = "select *, (Yuwen + Shuxue + Yingyu) as Totalscore from [Score] ORDER by Totalscore desc"; System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand (SQL, CN); System.Data.SqlClient.SqlDataReader dr = cmd. ExecuteReader (System.Data.CommandBehavior.CloseConnection); Gridview1.datasource = Dr; Gridview1.databind (); Dr. Close (); Cmd. Dispose (); cn. Dispose (); } protected void Gridview1_rowcreated (object sender, GridViewRowEventArgs e) {if (E.row.rowtype = = Datacontrolrowtype.datarow) {System.Data.Common.DbDataRecord db = (System.Data.Common.DbDataRecord) e. Row.dataitem; int totalscore = Int32.Parse (db[" Totalscore"]. ToString ()); if (E.row.rowindex = = 0) {Lastnumer = Totalscore;} if (Lastnumer!= totalscore) {trapezoidindex = E.row.rowindex + 1;} Lastnumer = Totalscore; }} </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id=" head1" Runat="server"> <title> Example of the GridView parallel rankings </title> </head> <body> <form id="form1" Runat="server"> <asp:gridview id=" gridview1" runat="server" autogeneratecolumns="false" onrowcreated=" gridview1_rowcreated" Width="600px"> < Columns> <asp:templatefield Headertext=" Data Serial number "> <ItemTemplate> <% #Container. Dataitemindex + 1%> </ItemTemplate> </asp:TemplateField> <asp:templatefield headertext=" Student Name "> <ItemTemplate> <% #Eval (" username")%> </ItemTemplate> </asp:TemplateField> <asp:templatefield headertext=" Language "> <ItemTemplate> <% #Eval (" yuwen")%> </ItemTemplate> </asp:TemplateField> <asp:templatefield headertext=" Mathematics "> <ItemTemplate> <% #Eval (" shuxue")%> </ItemTemplate> </asp:TemplateField> <asp:templatefield headertext=" English "> <ItemTemplate> <% #Eval (" yingyu")%> </itemtemplate> </asp:TemplateField> <asp:templatefield headertext=" Total Score "> <itemstyle font-bold="true" forecolor="red" /> <ItemTemplate> <% #Eval (" totalscore")%> </ItemTemplate> </asp:TemplateField> <asp:templatefield headertext=" Rankings "> <ItemTemplate> <% #TrapezoidIndex%> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> </body> </html>