evanheld
Newcomer
I am trying to populate a datalist so I can take advantage of the RepeatColumns() and RepeatDirection() functionality. After having problems getting it to populate, I dropped a datagrid on the form and assigned a datasource to it and called the databind() method using the same dataview object I am trying to use with the datalist. And it worked just fine!
Here is the code. This is all in the PageLoad() Sub.
Appreciate any suggestions:
If Not IsPostBack Then
Dim myUnit As Unit
Dim dt As New DataTable
Dim dr As DataRow
Dim i As Integer
Dim DS As New DataSet
Dim Data As New DataClass
DS = Data.QuerySQL("select FirstName, LastName from tblCustomer", "tblCustomer")
dt.Columns.Add(New DataColumn("First", GetType(String)))
dt.Columns.Add(New DataColumn("Last", GetType(String)))
For i = 0 To DS.Tables("tblCustomer").Rows.Count - 1
dr = dt.NewRow
dr(0) = DS.Tables("tblCustomer").Rows(i).Item("FirstName")
dr(1) = DS.Tables("tblCustomer").Rows(i).Item("LastName")
dt.Rows.Add(dr)
Next
Dim dv As New DataView(dt)
DataList1.Style("Top") = 20
DataList1.Style("Left") = 20
DataList1.Height = myUnit.Pixel(200)
DataList1.Width = myUnit.Pixel(200)
DataList1.Visible = True
'this doesn't work (why not??!!)
DataList1.DataSource = dv
DataList1.DataBind()
'Datagrid - this works!! But I need to use a DataList
DataGrid1.DataSource = dv
DataGrid1.DataBind()
End If
Here is the code. This is all in the PageLoad() Sub.
Appreciate any suggestions:
If Not IsPostBack Then
Dim myUnit As Unit
Dim dt As New DataTable
Dim dr As DataRow
Dim i As Integer
Dim DS As New DataSet
Dim Data As New DataClass
DS = Data.QuerySQL("select FirstName, LastName from tblCustomer", "tblCustomer")
dt.Columns.Add(New DataColumn("First", GetType(String)))
dt.Columns.Add(New DataColumn("Last", GetType(String)))
For i = 0 To DS.Tables("tblCustomer").Rows.Count - 1
dr = dt.NewRow
dr(0) = DS.Tables("tblCustomer").Rows(i).Item("FirstName")
dr(1) = DS.Tables("tblCustomer").Rows(i).Item("LastName")
dt.Rows.Add(dr)
Next
Dim dv As New DataView(dt)
DataList1.Style("Top") = 20
DataList1.Style("Left") = 20
DataList1.Height = myUnit.Pixel(200)
DataList1.Width = myUnit.Pixel(200)
DataList1.Visible = True
'this doesn't work (why not??!!)
DataList1.DataSource = dv
DataList1.DataBind()
'Datagrid - this works!! But I need to use a DataList
DataGrid1.DataSource = dv
DataGrid1.DataBind()
End If
Last edited: