MattP
Well-known member
VB.NET:
Imports System.Collections.Generic
Partial Class _Default
Inherits System.Web.UI.Page
Dim collection As New List(Of BlockRecord)
Dim entry As New BlockRecord
Protected Sub btnAddRecord_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddRecord.Click
With entry
.AcctNum = txtAcctNum.Text
.EntryDate = txtDate.Text
.DataSource = txtDataSource.Text
.AsOfDate = txtAsOfDate.Text
.Description = txtDescription.Text
.Description2 = txtDescription2.Text
.FileNameDesc = txtFileNameDesc.Text
.Amount = txtAmount.Text
.DebitCreditInd = txtDebitCreditInd.Text
End With
collection.Add(entry)
Me.GridView1.DataSource = collection
Me.GridView1.DataBind()
End Sub
End Class
Public Class BlockRecord
Private _AcctNum As Double
Private _EntryDate As Date
Private _DataSource As String
Private _AsOfDate As Date
Private _Description As String
Private _Description2 As String
Private _FileNameDesc As String
Private _Amount As Double
Private _DebitCreditInd As Double
Public Property AcctNum() As Double
Get
Return _AcctNum
End Get
Set(ByVal value As Double)
_AcctNum = value
End Set
End Property
Public Property EntryDate() As Date
Get
Return _EntryDate
End Get
Set(ByVal value As Date)
_EntryDate = value
End Set
End Property
Public Property DataSource() As String
Get
Return _DataSource
End Get
Set(ByVal value As String)
_DataSource = value
End Set
End Property
Public Property AsOfDate() As Date
Get
Return _AsOfDate
End Get
Set(ByVal value As Date)
_AsOfDate = value
End Set
End Property
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
Public Property Description2() As String
Get
Return _Description2
End Get
Set(ByVal value As String)
_Description2 = value
End Set
End Property
Public Property FileNameDesc() As String
Get
Return _FileNameDesc
End Get
Set(ByVal value As String)
_FileNameDesc = value
End Set
End Property
Public Property Amount() As Double
Get
Return _Amount
End Get
Set(ByVal value As Double)
_Amount = value
End Set
End Property
Public Property DebitCreditInd() As Double
Get
Return _DebitCreditInd
End Get
Set(ByVal value As Double)
_DebitCreditInd = value
End Set
End Property
End Class
Code works fine on the 1st itteration. When I attempt to add the second record rather than adding an additional entry to the list it overwrites it.
If someone could take a look at this and point out my error(s) it would be appreciated.
Thanks in advance.