Example of implementing parallel ranking in the GridView [access]

Source: Internet
Author: User

&amp; Lt; % @ Page Language = &amp; quot; C # &amp; quot; AutoEventWireup = &amp; quot; true &amp; quot; Debug = &amp; quot; true &amp; quot; % &amp; gt; &amp; lt; % @ Import Namespace = &amp; quot; System. data &amp; quot; % &amp; gt; &amp; lt; script runat = &amp; quot; server &amp; quot; &amp; gt; public int TrapezoidIndex = 1; int LastNumer = 0; protected void Page_Load (object sender, EventArgs e) {// ASPNET20Book. for more information about mdb databases, see ASP. NET 2.0 application development technology: the disc string ConnectionString =@&amp; quot; Provider = Microsoft. jet. OLEDB. 4.0; Data Source = | DataDirectory | \ ASPNET20Book. mdb; Persist Security Info = True &amp; quot; System. data. oleDb. oleDbConnection cn = new System. data. oleDb. oleDbConnection (ConnectionString); cn. open (); string SQL = &amp; quot; select * from [Score] Order BY Shuxue DESC &amp; quot; System. data. oleDb. oleDbCommand cmd = new System. data. oleDb. oleDbCommand (SQL, cn); System. data. oleDb. oleDbDataReader dr = cmd. executeReader (Command Behavior. 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 Shuxue = Int32.Parse (db [&amp; quot; Shuxue &amp; quot;]. toString (); if (e. row. rowInde X = 0) {LastNumer = Shuxue;} if (LastNumer! = Shuxue) {TrapezoidIndex = e. Row. RowIndex + 1 ;}lastnumer = Shuxue ;}&amp; lt;/script &amp; gt; &amp; lt; html xmlns = &amp; quot; http://www.w3.org/1999/xhtml"&gt;<pead Id = &amp; quot; Head1 &amp; quot; runat = &amp; quot; server &amp; quot; &amp; gt; &amp; lt; title &amp; gt; examples of simultaneous ranking of GridView &amp; lt; /title &amp; gt; &amp; lt;/head &amp; gt; &amp; lt; body &amp; gt; &amp; lt; form id = &amp; quot; form1 &amp; quot; runat = &amp; quot; server &amp; quot; &amp; gt; &amp; lt; asp: GridView ID = &amp; quot; GridView1 &amp; quot; runat = &amp; quot; server &amp; quot; AutoGenerateColumns = &amp; quot; false &amp; quot; onRowCreated = &amp; quot; GridView1_RowCreated &amp; quot; &amp; gt; &amp; lt; Columns &amp; gt; &amp; lt; asp: TemplateField HeaderText = &amp; quot; Data No. &amp; quot; &amp; gt; &amp; lt; ItemTemplate &amp; gt; &amp; lt; % # Container. dataItemIndex + 1% &amp; gt; &amp; lt;/ItemTemplate &amp; gt; &amp; lt;/asp: TemplateField &amp; gt; &amp; lt; asp: TemplateField HeaderText = &amp; quot; Student name &amp; quot; &amp; gt; &amp; lt; ItemTemplate &amp; gt; &amp; lt; % # Eval (&amp; quot; UserName &amp; quot;) % &amp; gt; &amp; lt;/ItemTemplate &amp; gt; &amp; lt; /asp: TemplateField &amp; gt; &amp; lt; asp: TemplateField HeaderText = &amp; quot; mathematics &amp; quot; &amp; gt; &amp; lt; ItemTemplate &amp; gt; &amp; lt; % # Eval (&amp; quot; Shuxue &amp; quot;) % &amp; gt; &amp; lt;/ItemTemplate &amp; gt; &amp; lt;/asp: TemplateField &amp; gt; &amp; lt; asp: templateField HeaderText = &amp; quot; ranking &amp; quot; &amp; gt; &amp; lt; ItemTemplate &amp; gt; &amp; lt ;%# TrapezoidIndex % &amp; gt; &amp; lt;/ItemTemplate &amp; gt; &amp; lt;/asp: TemplateField &amp; gt; &amp; lt;/Columns &amp; gt; &amp; lt;/asp: GridView &amp; gt; &amp; lt;/form &amp; gt; &amp; lt; /body &amp; gt; &amp; lt;/html &amp; gt;

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.