|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can GridView bind to a standalone DataTableI have a type DataTable, it does exist in a DataSet.
How could I bind this DataTable to a GridView? "ad" <fly***@wfes.tcc.edu.tw> wrote in message news:%23$nJdVBmGHA.4816@TK2MSFTNGP03.phx.gbl... Ad,>I have a type DataTable, it does exist in a DataSet. > How could I bind this DataTable to a GridView? > 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. But my DataTable like MyTable is a stand alnoe DataTable, it do not belong
to any DataSet. How can I do? Show quote "Carl Prothman" <c***@prothman.online.org> ¼¶¼g©ó¶l¥ó·s»D:%23%237dFQOmGHA.4***@TK2MSFTNGP03.phx.gbl... > "ad" <fly***@wfes.tcc.edu.tw> wrote in message > news:%23$nJdVBmGHA.4816@TK2MSFTNGP03.phx.gbl... >>I have a type DataTable, it does exist in a DataSet. >> How could I bind this DataTable to a GridView? >> > > 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 > |
|||||||||||||||||||||||