{ SqlConnection myConnection = new SqlConnection(strConnectSQL); SqlCommand myCommand = new SqlCommand( SQLstring, myConnection ); myConnection.Open();
Dlist.DataSource = myCommand.ExecuteReader(); Dlist.DataTextField = TextField; Dlist.DataValueField = ValueField; Dlist.DataBind();
myConnection.Close(); }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } 有趣的地方这样做的好处之一就是你可以在ASP.NET中指定 web 控件作为函数的输入参数。这确实改变了我的编码习惯,我现在正在开发更多的一般性的可重用代码。 为什么使用这些代码这非常简单。一旦你要为一个特定的控件编码,你就不必再重新写一次了。你可以一次又一次地使用相同的代码。 历史2004年11月 V1.1
上一页 [1] [2] [3] [4] |