|
 |
aspx thread: Datatable
Message #1 by "Amit Kalani" <kalani@w...> on Fri, 27 Oct 2000 15:35:04 -0400
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0113_01C0402B.7A590680
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I am having a DataSet with two tables: Inventory and Sales.
Now I wish to display a grid with a mix of columns from both tables and
few additional columns.
Any Ideas what is the best way to do it?
Message #2 by "Fredrik Normen" <fredrik.normen@e...> on Sun, 29 Oct 2000 12:26:16 +0100
|
|
It look like there is no solution for this in the pre-beta=2E
( Correct me if I=27m wrong )
You could create a DataTable and add some rows to it and bind it to a
DataGrid=2E=2E
Example=3A
Dim dt As DataTable
Dim dr As DataRow
=27create a DataTable
dt =3D New DataTable
dt=2EColumns=2EAdd(New DataColumn(=22StringValue=22=2C GetType(String)))
dt=2EColumns=2EAdd(New DataColumn(=22StringValue=22=2C GetType(String)))
dr =3D dt=2ENewRow()
dr(0) =3D =22Fredrik=22
dr(1) =3D =22Norm=E9n=22
=27add the row to the datatable
dt=2ERows=2EAdd(dr)
dataGrid1=2EDataSource =3D new DataView(dt)
dataGrid1=2EDataBind
In Beta 2 you can bind a dataset to a datagrid=3A
DataGrid1=2EDataSource =3D DataSet
And I think it will be possible to choose any columns from any of the
tables in the dataset=2E
I think the release of beta 2 will be in March 2001 or something=2E
My suggestion is that you creata a realation between the two tables and
create you own grid=2E
For example=3A
Dim myConnection as SQLConnection =3D new SQLConnection
(=22server=3Dlocalhost=3Buid=3Dsa=3Bpwd=3D=3Bdatabase=3Dnorthwind=22)
Dim CustomersDSCommand as SQLDataSetCommand =3D new
SQLDataSetCommand(=22select * from customers=22=2C myConnection)
Dim OrdersDSCommand as SQLDataSetCommand =3D new SQLDataSetCommand
(=22select * from orders=22=2C myConnection)
Dim dsCustomers as DataSet =3D new DataSet
CustomersDSCommand=2EFillDataSet(dsCustomers=2C=22Customers=22)
OrdersDSCommand=2EFillDataSet(dsCustomers=2C=22Orders=22)
=27ADD RELATION
dsCustomers=2ERelations=2EAdd(=22CustOrders=22=2CdsCustomers=2ETables
(=22Customers=22)=2EColumns(=22CustomerId=22)=2CdsCustomers=2ETables(=22O
rders=22)=2EColumns
(=22CustomerId=22))
Dim Customer as DataRow
Dim Order as Object
for each Customer in dsCustomers=2ETables(=22Customers=22)=2ERows
Response=2EWrite(=22=3Cbr=3ECustomer=3A =22 + Customer
(=22ContactName=22)=2EToString())
Response=2EWrite(=22=3Cblockquote=3E=22)
for each Order in Customer=2EGetChildRows
(dsCustomers=2ERelations(=22CustOrders=22))
Response=2EWrite(=22=3Cbr=3EOrder =23=22 + Order
(=22OrderId=22)=2EToString())
next
Response=2EWrite(=22=3C/blockquote=3E=22)
next
/Fredrik Normen
----- Original Message -----
From=3A =22Amit Kalani=22 =3Ckalani=40writeme=2Ecom=3E
Date=3A Friday=2C October 27=2C 2000 9=3A35 pm
Subject=3A =5Baspx=5D Datatable
=3E I am having a DataSet with two tables=3A Inventory and Sales=2E
=3E Now I wish to display a grid with a mix of columns from both
=3E tables and few additional columns=2E
=3E
=3E Any Ideas what is the best way to do it=3F
=3E
=3E
=3E ---
=3E Wrox Professional Web Developer Conference II
=3E http=3A//www=2Ewroxconferences=2Ecom/WebDevEurope
=3E November 29th - December 1st 2000=2C Amsterdam=2C Netherlands
=3E Create powerful distributed web applications serving you now and
=3E in the future=2E From ASP+ and VB=2ENET to XML and SQL Server 2000
=3E ---
=3E You are currently subscribed to aspx as=3A fredrik=2Enormen=40endero=2E
com
=3E To unsubscribe send a blank email to leave-aspx-18463N=40p2p=2Ewrox=2E
com
=3E
=3E
|
|
 |