Hi All,
I have a databinding issue with one of my web forms. Basically I have created a class, which has the following syntax:
Public Class EmployeeHolidaysDates
Private _EmployeeNo As Integer
Private _BeginDate As Date
Private _EndDate As Date
Private _Actual As Integer
Private _ID As Integer
Private _ManID As Integer
Public Property EmployeeNo() As Integer
Get
Return _EmployeeNo
End Get
Set(ByVal value As Integer)
_EmployeeNo = value
End Set
End Property
Public Property BeginDate() As Date
Get
Return _BeginDate
End Get
Set(ByVal value As Date)
_BeginDate = value
End Set
End Property
Public Property EndDate() As Date
Get
Return _EndDate
End Get
Set(ByVal value As Date)
_EndDate = value
End Set
End Property
Public Property Actual() As Double
Get
Return _Actual
End Get
Set(ByVal value As Double)
_Actual = value
End Set
End Property
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property
Public Property ManagerID() As Integer
Get
Return _ManID
End Get
Set(ByVal value As Integer)
_ManID = value
End Set
End Property
End Class
Basically I get a list of Employee Holiday dates from the DataBase and store it in a List of the above class. I then pass this list to a sub to create a DataTable to enable me to bind this data to a repeater control. When I bind the data, the repeater shows the correct number of rows, but no text data is shown and I have no idea why.
Below is my BuildData sub
Public Sub BuildData(ByVal myHolidayList As List(Of EmployeeDetailsClass.EmployeeHolidaysDates))
Dim myHol As New EmployeeDetailsClass.EmployeeHolidaysDates
Dim DTable As New DataTable
Dim DColumn As DataColumn
Dim DRow As DataRow
DColumn = New DataColumn()
DColumn.DataType = System.Type.GetType("System.String")
DColumn.ColumnName = "Name"
DTable.Columns.Add(DColumn)
DColumn = New DataColumn()
DColumn.DataType = Type.GetType("System.DateTime")
DColumn.ColumnName = "StartDate"
DTable.Columns.Add(DColumn)
DColumn = New DataColumn()
DColumn.DataType = Type.GetType("System.DateTime")
DColumn.ColumnName = "EndDate"
DTable.Columns.Add(DColumn)
For Each myHol In myHolidayList
DRow = DTable.NewRow
DRow("Name") = GetName(myHol.EmployeeNo)
DRow("StartDate") = myHol.BeginDate.ToString
DTable.Rows.Add(DRow)
Next
Dim DView As New DataView(DTable)
DView.Sort = "Name"
Dim PDSource As New PagedDataSource()
PDSource.DataSource = DView
PDSource.AllowPaging = True
PDSource.PageSize = RecordsPerPage
PDSource.CurrentPageIndex = CurrentPage - 1
Repeater1.DataSource = PDSource
Repeater1.DataBind()
DView = Nothing
DTable = Nothing
End Sub
(I have ommitted some of the members for clarity)
If anyone could tell me why this is happening I would be most grateful.
Thanks
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).