ASP. Code populate foreground data instance

Source: Internet
Author: User

The. aspx code is as follows:

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default12.aspx.cs" inherits= "Default12"%><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

The. Aspx.cs code is as follows:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using  System.web.ui.webcontrols;using System.data.oledb;public Partial class default12:system.web.ui.page{string str_cnn = "Provider=Microsoft.Jet.OLEDB.4.0;    Data source= ";    String str_sourcefile = "Mdb\\mydb.mdb";    OleDbConnection CNN;    OleDbCommand cmd;    OleDbDataReader Datar;    String Str_sql; protected void Page_Load (object sender, EventArgs e) {//Build Table//"Chinese" failed, "Chinese" Excellent, "mathematics" failed, "mathematics" excellent//[go        Od]_cj_yuwen,[fail]_cj_yuwen,[good]_cj_shuxue,[fail]_cj_shuxue string[] _sarr1 = {"Good", "Fail"};        String[] _sarr2 = {"Excellent", "failed"};        String[] _sarr_km = {"Cj_yuwen", "Cj_shuxue", "Cj_huaxue", "Cj_wuli", "Cj_yingyu"};        String[] _sarr_kmname = {"Language", "Mathematics", "chemistry", "Physics", "English"}; TableRow _tr;        TableCell _td; for (int i = 0; i < _sarr_km. Length;            i++) {_tr = new TableRow (); for (int j = 0; J &Lt _sarr1. Length;                J + +) {_td = new TableCell (); _td.                Text = _sarr_kmname[i] + _sarr2[j]; _tr.                Cells.add (_TD);                _TD = new TableCell ();                _td.id = _sarr1[j] + _sarr_km[i]; _tr.            Cells.add (_TD); } tbl_summary.        Rows.Add (_TR);        } string str_conn = Str_cnn + MapPath (str_sourcefile);        CNN = new OleDbConnection (Str_conn); Cnn.        Open ();        Str_sql = "SELECT * from Tb_chenji";        cmd = new OleDbCommand (Str_sql, CNN); Datar = cmd.        ExecuteReader ();        Label Lab_name;        Single _f; while (Datar. Read ()) {//lab_name = new Label (); Lab_name. Text = datar["Cj_name"].            ToString (); foreach (String _skm in _sarr_km) {_f = Convert.tosingle (datar[_skm]. ToString ());//&LT;STRONG&GT;&LT;EM&GT;_SKM is important both as a variable name and as a factor for building IDs </em></strong> if (_f < 60 ) {lab_name = new Label (); Lab_name. Text = datar["Cj_name"].                    ToString ();                    _TD = (TableCell) FindControl ("Fail" + _skm); _td.                Controls.Add (Lab_name); } if (_f >) {lab_name = new Label (); Lab_name. Text = datar["Cj_name"].                    ToString ();                    _TD = (TableCell) FindControl ("good" + _skm); _td.                Controls.Add (Lab_name); }}} CNN.    Close (); }}

The effect is as follows:


ASP. Code populate foreground data instance

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.