asp.net datagrid not showing
-
when adding the datagrid component and executing the asp web page it does not display ..Tried this on 3 diff computers and he result is same .The web page its self does not contain the datagrid control when executed .. Same goes for the dataList/table .... code.aspx.cs ------------
private OleDbConnection conn = new OleDbConnection(@"Provider = Microsoft.Jet.OleDb.4.0; Data Source = C:\Shirazagro.mdb"); private OleDbCommand cmd; private OleDbDataAdapter dataAdap; protected System.Web.UI.WebControls.DataGrid DataGrid1; private DataTable dt = new DataTable(); protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e) { cmd = new OleDbCommand( "select * from supplier", conn ); dataAdap = new OleDbDataAdapter( cmd ); dataAdap.Fill( dt ); Response.Write( dt.Rows[0]["SupName"].ToString() ); DataGrid1.DataBind(); TextBox1.DataBind(); TextBox2.DataBind(); //DataGrid1.DataSource = dt; }
code.aspx ---------- -
when adding the datagrid component and executing the asp web page it does not display ..Tried this on 3 diff computers and he result is same .The web page its self does not contain the datagrid control when executed .. Same goes for the dataList/table .... code.aspx.cs ------------
private OleDbConnection conn = new OleDbConnection(@"Provider = Microsoft.Jet.OleDb.4.0; Data Source = C:\Shirazagro.mdb"); private OleDbCommand cmd; private OleDbDataAdapter dataAdap; protected System.Web.UI.WebControls.DataGrid DataGrid1; private DataTable dt = new DataTable(); protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e) { cmd = new OleDbCommand( "select * from supplier", conn ); dataAdap = new OleDbDataAdapter( cmd ); dataAdap.Fill( dt ); Response.Write( dt.Rows[0]["SupName"].ToString() ); DataGrid1.DataBind(); TextBox1.DataBind(); TextBox2.DataBind(); //DataGrid1.DataSource = dt; }
code.aspx ----------Hi di, You need to uncomment this line, and place it before DataGrid1.DataBind(): //DataGrid1.DataSource = dt; Hope that helps! Marcie CP Blog[^]