-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestData.vb
65 lines (57 loc) · 1.71 KB
/
TestData.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Imports System.ComponentModel
Public Class DataRow
Private fId As Integer
Private fDescription As String
Public Sub New(ByVal id As Integer, ByVal description As String)
fId = id
fDescription = description
End Sub
Public Property ID() As Integer
Get
Return fId
End Get
Set(ByVal value As Integer)
fId = value
End Set
End Property
Public Property Description() As String
Get
Return fDescription
End Get
Set(ByVal value As String)
fDescription = value
End Set
End Property
End Class
Public Class GridDataSource
Private ReadOnly Property Session() As HttpSessionState
Get
Return HttpContext.Current.Session
End Get
End Property
Public Function GetRows() As BindingList(Of DataRow)
If Session("GridDataSource") Is Nothing Then
CreateRows()
End If
Return TryCast(Session("GridDataSource"), BindingList(Of DataRow))
End Function
Public Sub CreateRows()
Dim res As BindingList(Of DataRow) = New BindingList(Of DataRow)()
For i As Integer = 1 To 25
Dim item As New DataRow(i, "Sample data for row " & i)
res.Add(item)
Next i
Session("GridDataSource") = res
End Sub
Public Sub DeleteRow(ByVal id As Integer)
Dim rows As BindingList(Of DataRow) = TryCast(Session("GridDataSource"), BindingList(Of DataRow))
Dim i As Integer = 0
Do While i < rows.Count
If rows(i).ID = id Then
rows.Remove(rows(i))
Exit Do
End If
i += 1
Loop
End Sub
End Class