下面是我将Stu表中的数据绑定到Datagrid控件中的程序,运行后已经成功绑定了private void InitializeComponent()
{ string select = "SELECT * FROM Stu";
string source = "data source=SERVER;initial catalog=Test;persist security info=False;user id=sa;wo" +"rkstation id=CENTER-5;packet size=4096";
System.Data.SqlClient.SqlConnection conn = new SqlConnection(source);
System.Data.SqlClient.SqlDataAdapter adapter = new SqlDataAdapterselect,conn);
System.Data.DataSet ds = new DataSet();
adapter.Fill(ds,"Stu");
DataGrid1.DataSource = ds.Tables["Stu"].DefaultView;
DataGrid1.DataBind();  
}
我想问的是,当我向DataGrid中增加一个按钮列时,在运行该程序,则页面上什么都没有显示,当我再去检查代码时,却变成了下面的了?请问我先前的代码为什么回没有了?
是不是我代码的位置写错了?请高手指教!!
private void InitializeComponent()
{    
this.ds = new System.Data.DataSet();
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
// ds
this.ds.DataSetName = "NewDataSet";
this.ds.Locale = new System.Globalization.CultureInfo("zh-CN");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
}