I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView?
A ad Jun 25, 2006 #1 I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView?
C Carl Prothman Jun 26, 2006 #2 ad said: I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView? Click to expand... Ad, Just set the DataSource property, then call DataBind() method. gridView1.DataSource = dataSet1.Tables["MyTableName"]; gridView1.DataBind(); The GridView can also be bound to a data source control. e.g. SqlDataSource http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx - Note this is the preferred method to bind to data. -- Thanks, Carl Prothman Microsoft ASP.NET MVP http://www.CarlProthman.NET
ad said: I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView? Click to expand... Ad, Just set the DataSource property, then call DataBind() method. gridView1.DataSource = dataSet1.Tables["MyTableName"]; gridView1.DataBind(); The GridView can also be bound to a data source control. e.g. SqlDataSource http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx - Note this is the preferred method to bind to data. -- Thanks, Carl Prothman Microsoft ASP.NET MVP http://www.CarlProthman.NET
A ad Jun 26, 2006 #3 But my DataTable like MyTable is a stand alnoe DataTable, it do not belong to any DataSet. How can I do? Carl Prothman said: ad said: I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView? Click to expand... Ad, Just set the DataSource property, then call DataBind() method. gridView1.DataSource = dataSet1.Tables["MyTableName"]; gridView1.DataBind(); The GridView can also be bound to a data source control. e.g. SqlDataSource http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx - Note this is the preferred method to bind to data. -- Thanks, Carl Prothman Microsoft ASP.NET MVP http://www.CarlProthman.NET Click to expand...
But my DataTable like MyTable is a stand alnoe DataTable, it do not belong to any DataSet. How can I do? Carl Prothman said: ad said: I have a type DataTable, it does exist in a DataSet. How could I bind this DataTable to a GridView? Click to expand... Ad, Just set the DataSource property, then call DataBind() method. gridView1.DataSource = dataSet1.Tables["MyTableName"]; gridView1.DataBind(); The GridView can also be bound to a data source control. e.g. SqlDataSource http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx - Note this is the preferred method to bind to data. -- Thanks, Carl Prothman Microsoft ASP.NET MVP http://www.CarlProthman.NET Click to expand...
C Carl Prothman Jun 26, 2006 #4 ad said: But my DataTable like MyTable is a stand alnoe DataTable, it do not belong to any DataSet. How can I do? Click to expand... gridView1.DataSource = myDataTable; gridView1.DataBind();
ad said: But my DataTable like MyTable is a stand alnoe DataTable, it do not belong to any DataSet. How can I do? Click to expand... gridView1.DataSource = myDataTable; gridView1.DataBind();