private void Page_Load(object sender, System.EventArgs e)
{
string board;
if(Request["board"] == null)
board = "5";
else
board = Request["board"];
this.sqlSelectCommand1.CommandText = "SELECT Title, FileName, PostTime, Status, Click, Reply, LastReply, ID FROM BBS WHERE Board = " + board + " order by LastReply desc";
this.sqlDataAdapter1.Fill(this.bbsDataSet1,"BBS");
this.DataGrid1.CurrentPageIndex = 0;
this.DataGrid1.DataBind();
}
#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();
this.sqlConnection1.ConnectionString = (string)Application["ConnectionString"];
this.sqlSelectCommand1.CommandText = "SELECT Title, FileName, PostTime, Status, Click, Reply, LastReply, Score, ID FROM BBS WHERE (Board = " + Request["board"] + ")";
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.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.bbsDataSet1 = new bbs.BBSDataSet();
this.dataView1 = new System.Data.DataView();
((System.ComponentModel.ISupportInitialize)(this.bbsDataSet1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "BBS", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Title", "Title"),
new System.Data.Common.DataColumnMapping("FileName", "FileName"),
new System.Data.Common.DataColumnMapping("PostTime", "PostTime"),
new System.Data.Common.DataColumnMapping("Status", "Status"),
new System.Data.Common.DataColumnMapping("Click", "Click"),
new System.Data.Common.DataColumnMapping("Reply", "Reply"),
new System.Data.Common.DataColumnMapping("LastReply", "LastReply"),
new System.Data.Common.DataColumnMapping("Score", "Score")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Title, FileName, PostTime, Status, Click, Reply, LastReply, Score, ID FROM" +
" BBS WHERE (Board = N\1\)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "data source=LUYANSC;initial catalog=BBS;integrated security=SSPI;persist security" +
" info=False;workstation id=LUYANSC;packet size=4096";
//
// bbsDataSet1
//
this.bbsDataSet1.DataSetName = "BBSDataSet";
this.bbsDataSet1.Locale = new System.Globalization.CultureInfo("zh-CN");
this.bbsDataSet1.Namespace = "http://www.tempuri.org/BBSDataSet.xsd";
//
// dataView1
//
this.dataView1.Table = this.bbsDataSet1.BBS;
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.bbsDataSet1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
}
#endregion
请问,象上面的几个自动生成的方法中,执行顺序是怎么样的??
相信很多初学的人都弄不太清。
请高手们指教一下!!
首先执行Page_Load(),而Page_Load()里边又调用 InitializeComponent()。
DataGrid1_PageIndexChanged()是事件驱动的,只有触发了这个事件,才会调用。