I am trying to get a list of Dates and times to show up dynamically in a GridView. I couldn't figure out how to format it properly using an AccessDataSource so instead I decided to code it myself.
I've gotten it to put data from the access database into the DataTable, and I've then transferred it into a DataView. However, whenever I try to DataBind it, it doesn't seem to do anything. I've spent several hours trying to figure it out, and tracking it line by line and have come up with nothing. Am I approaching it the wrong way?
Code:
Dim Roster As DataTable = New DataTable()
Roster.Columns.Add(New DataColumn("Day", GetType(String)))
Roster.Columns.Add(New DataColumn("Start", GetType(String)))
Roster.Columns.Add(New DataColumn("Finish", GetType(String)))
Dim getData As New OleDbCommand("SELECT Roster.Date, Roster.Start, Roster.Finish FROM UserDetail INNER JOIN Roster ON UserDetail.UserID = Roster.UserID WHERE (UserDetail.UserName)='Jason';", myConnection)
Dim rosData As OleDbDataReader
myConnection.Open()
rosData = getData.ExecuteReader()
Do While rosData.Read()
Dim dRow As DataRow = Roster.NewRow()
dRow.Item(0) = DateTime.Parse(rosData.Item(0)).DayOfWeek.ToString()
dRow.Item(1) = DateTime.Parse(rosData.Item(1)).TimeOfDay.ToString()
dRow.Item(2) = DateTime.Parse(rosData.Item(2)).TimeOfDay.ToString()
Roster.Rows.Add(dRow)
Loop
myConnection.Close()
Dim RosterView As DataView = New DataView(Roster)
If Not RosterView Is Nothing Then
RosterGrid.DataSource = RosterView
RosterGrid.DataBind()
RosterGrid.Visible = True
End If