I use a component that only takes a datatable,dataset or a dataview as datasource.
Is there any simple way to convert the ilist to a datatable or do i have to loop all the posts and insert them into the datatable?
I create the datatable like this
Code:
Dim dt As New DataTable
Dim dtc, dtc1, dtc2, dtc3, dtc4, dtc5, dtc6 As DataColumn
dtc = New DataColumn
dtc1 = New DataColumn
dtc2 = New DataColumn
dtc3 = New DataColumn
dtc4 = New DataColumn
dtc5 = New DataColumn
dtc6 = New DataColumn
With dtc
.ColumnName = "ID"
.DataType = System.Type.GetType("System.Int32")
End With
With dtc1
.ColumnName = "gameID"
.DataType = System.Type.GetType("System.Int32")
End With
With dtc2
.ColumnName = "teamID"
.DataType = System.Type.GetType("System.Int32")
End With
With dtc3
.ColumnName = "startTime"
.DataType = System.Type.GetType("System.DateTime")
End With
With dtc4
.ColumnName = "endTime"
.DataType = System.Type.GetType("System.DateTime")
End With
With dtc5
.ColumnName = "eventDate"
.DataType = System.Type.GetType("System.DateTime")
End With
With dtc6
.ColumnName = "Task"
.DataType = System.Type.GetType("System.String")
End With
With dt
.Columns.Add(dtc)
.Columns.Add(dtc1)
.Columns.Add(dtc2)
.Columns.Add(dtc3)
.Columns.Add(dtc4)
.Columns.Add(dtc5)
.Columns.Add(dtc6)
End With
Dim dtr As DataRow
For Each e As tik2005.schedule1 In scheduleDB.getSchedule(startDate, endDate)
dtr = dt.NewRow
dtr("ID") = e.ID
dtr("gameID") = e.gameID
dtr("teamID") = e.teamID
dtr("startTime") = e.startTime
dtr("endTime") = e.endTime
dtr("eventDate") = e.eventDate
dtr("Task") = e.Task
dt.Rows.Add(dtr)
Next