Front
<% # Getstr (eval ("isdonebycompany"). tostring () %>
Background
Protected string getstr (string boo)
{
If ("false". equals (boo ))
{
Return "unfinished ";
}
Else
{
Return "completed ";
}
}
Asp tutorial. net binding
Databinder. eval binding does not require you to care about the data source (dataread or dataset ). The data type eval will convert the data object into a string. It does a lot of work on the underlying binding and uses the reflection performance. This is because it is easy to use, but affects data performance. When dataset is bound, dataitem is actually a datarowview (if it is bound to a data reader (dataread), it is an idatarecord .) Therefore, directly converting to datarowview will greatly improve the performance.
9q gws3aq1i) u0 odd network media-bo Baiyou IT network policyf} 2j :? W1k # t
Note: 1. Pay attention to the Case sensitivity of Field Names (special attention ). If it is inconsistent with the query, it may lead to a slower speed in some cases. 2. If you want to further increase the speed, you can use this method. But its readability is not high.
Namespace my23up. my23up_control
{
Using system;
Using system. data;
Using system. drawing;
Using system. web;
Using system. web. ui. webcontrols;
Using system.web.ui.html controls;
Using system. configuration;
Using system. data. sqlclient;
/// <Summary>
/// Summary of bbs_articleview.
/// </Summary>
Public class bbs_articleview: system. web. ui. usercontrol
{
Protected system. web. ui. webcontrols. repeater myrepeater;
Private void page_load (object sender, system. eventargs e)
{
String myconn = configurationsettings. apps tutorial ettings ["connectionstring"]. tostring (). trim ();
Sqlconnection myconnection = new sqlconnection (myconn );
String mycommandstring = "select * from article ";
Sqldataadapter myadapter = new sqldataadapter (mycommandstring, myconnection );
Dataset mydataset = new dataset ();
Myadapter. fill (mydataset, "mydatatable1 ");
Myrepeater. datasource = mydataset. tables ["mydatatable1"]. defaultview;
Myrepeater. databind ();
}
# Code generated by region web Form Designer
Override protected void oninit (eventargs e)
{
//
// Codegen: This call is required by the asp tutorial. net web form designer.
//
Initializecomponent ();
Base. oninit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor
/// Modify the content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}
================================== The following is the articleview. aspx. cs ==================================
Using system;
Using system. collections;
Using system. componentmodel;
Using system. data;
Using system. drawing;
Using system. web;
Using system. web. sessionstate;
Using system. web. ui;
Using system. web. ui. webcontrols;
Using system.web.ui.html controls;
Namespace my23up. bbs
{
/// <Summary>
/// Summary of articleview.
/// </Summary>
Public class articleview: system. web. ui. page
{
Private void page_load (object sender, system. eventargs e)
{
// Place user code here to initialize the page
}
# Code generated by region web Form Designer
Override protected void oninit (eventargs e)
{
//
// Codegen: This call is required by the web form designer of the asp.net tutorial.
//
Initializecomponent ();
Base. oninit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}
==================================== The following is the articleview. aspx html page ================================
<% @ Page language = "c #" codebehind = "articleview. aspx. cs" autoeventwireup = "false" inherits = "my23up. bbs. articleview" %>
<% @ Register tagprefix = "uc1" tagname = "bbs_articleview" src = "../my23up_control/bbs_articleview.ascx" %>
<! Doctype html public "-// w3c // dtd html 4.0 transitional // en">
<Html>
<Head>
<Title> articleview </title>
<Meta name = "generator" content = "microsoft visual studio. net 7.1">
<Meta name = "code_language" content = "c #">
<Meta name = "vs_defaultclientscript" content = "javascript tutorial">
<Meta name = "vs_targetschema" content = "http: // bKjia. c0m/intelliisense/ie5">
</Head>
<Body>
<Form id = "form1" method = "post" runat = "server">
<Font face = "">
<Uc1: bbs_articleview id = "bbs_articleview1" runat = "server"> </uc1: bbs_articleview> </font>
</Form>
</Body>
</Html>