基本用法 namespace exchange { using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Web; using System.Security.Cryptography; public class newjoin : System.Web.UI.UserControl { protected DataList newjoinlist; public newjoin() { this.Init += new System.EventHandler(Page_Init); } protected void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { LoadData(); } } protected void LoadData() { String StrSql = "select top 10 id,left(corpname,13) as corpname from crop order by id desc"; MyDataOp mdo = new MyDataOp(StrSql); DataSet ds = mdo.CreateDataSet(); newjoinlist.DataSource = ds.Tables[0].DefaultView; newjoinlist.DataBind(); mdo.Close(); } private void Page_Init(object sender, EventArgs e) { InitializeComponent(); } private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } } } 用起来挺方便的!
|