Elton,
Here is the code. The url you indicate is not dynamically created
datagrid in VB. Those datagrids are created at the design time. You
just set the datasource later. Of course, you could see the datasource
property.
My question is for the datagrid which is created at run time. Then
there is no datasouce property in VB.net but there is this property in
C#. I do thing sometime C# has more power than VB.NET.
Public Sub CreateGrid()
'declare a new datagrid and set properties
Dim DataGrid1 As New DataGrid()
DataGrid1.ShowHeader = True
DataGrid1.AutoGenerateColumns = False
DataGrid1.SelectedItemStyle.BackColor = Color.Yellow
'add bound columns to the datagrid
Dim datagridcol As New BoundColumn()
datagridcol.HeaderText = "Last Name"
datagridcol.DataField = "lastname"
DataGrid1.Columns.Add(datagridcol)
datagridcol = New BoundColumn()
datagridcol.HeaderText = "First Name"
datagridcol.DataField = "firstname"
DataGrid1.Columns.Add(datagridcol)
'bind datagrid
'*************************************
'I will get error in here and tell me that
'datasource is not the property of DataGrid1
DataGrid1.DataSource = GetDataSet()
DataGrid1.DataBind()
'add datagrid to the page
Page.Controls(1).Controls.Add(DataGrid1)
End Sub
thanks,
Donna