A
Arpan
The following code snippet creates a DataSet on the fly which is then passed to a DataView so that the DataSet can finally be viewed in a DataGrid control:
'Create the empty DataSet
Dim objDS As New DataSet("MyDataSet")=CreateDataSet()
'Create the new table & add columns
Dim dTable As New DataTable("Users")
dTable.Columns.Add("ID",System.Type.GetType("System.Int32"))
dTable.Columns.Add("FirstName",System.Type.GetType("System.String"))
dTable.Columns.Add("LastName",System.Type.GetType("System.String"))
dTable.Columns("ID").AutoIncrement=True
'Add the new table to the DataSet's TableCollection
objDS.Tables.Add(dTable)
'Define the Primary Key
Dim dColumn As DataColumn={objDS.Tables("Users").Columns("ID")}
objDS.Tables("Users").PrimaryKey=dColumn
'Add a row to this table
Dim dRow As DataRow=dTable.NewRow()
dRow(1)="Celine"
dRow(2)="Dion"
dTable.Rows.Add(dRow)
Dim objDV As New DataView
objDV.Table=objDS.Tables("Users")
myDataGrid.DataSource=objDV
myDataGrid.DataBind()
Function CreateDataSet
Dim objDS As DataSet=New DataSet("Users")
objDS.Tables.Add(dTable)
Return objDS
End Function
<aspataGrid id="myDataGrid" runat=server/>
As such the above code doesn't generate any error but the DataSet isn't getting displayed in the DataGrid! Where am I going wrong?
Please be informed that I am a newbie in ASP.NET & am working on Windows 2000 Professional.
Thanks,
Arpan
'Create the empty DataSet
Dim objDS As New DataSet("MyDataSet")=CreateDataSet()
'Create the new table & add columns
Dim dTable As New DataTable("Users")
dTable.Columns.Add("ID",System.Type.GetType("System.Int32"))
dTable.Columns.Add("FirstName",System.Type.GetType("System.String"))
dTable.Columns.Add("LastName",System.Type.GetType("System.String"))
dTable.Columns("ID").AutoIncrement=True
'Add the new table to the DataSet's TableCollection
objDS.Tables.Add(dTable)
'Define the Primary Key
Dim dColumn As DataColumn={objDS.Tables("Users").Columns("ID")}
objDS.Tables("Users").PrimaryKey=dColumn
'Add a row to this table
Dim dRow As DataRow=dTable.NewRow()
dRow(1)="Celine"
dRow(2)="Dion"
dTable.Rows.Add(dRow)
Dim objDV As New DataView
objDV.Table=objDS.Tables("Users")
myDataGrid.DataSource=objDV
myDataGrid.DataBind()
Function CreateDataSet
Dim objDS As DataSet=New DataSet("Users")
objDS.Tables.Add(dTable)
Return objDS
End Function
<aspataGrid id="myDataGrid" runat=server/>
As such the above code doesn't generate any error but the DataSet isn't getting displayed in the DataGrid! Where am I going wrong?
Please be informed that I am a newbie in ASP.NET & am working on Windows 2000 Professional.
Thanks,
Arpan