Dynamic ArrayList Datagrid

i have created a arraylist, class -> Code snippet

Everything works fine except only one row of record show on the datagrid. am i over-writing the details.

What m i doing wrong here. please help me to solve this
Public Class DisputeSalesItem
    Private m_ItemCode As String
    Private m_ItemDesc As String
    Private m_UnitPrice As Decimal
    Private m_Quantitiy As Integer
    Private m_Discount As Decimal
    Private m_LineTotal As Decimal
    Public Sub New(ByVal ItemCode As String, ByVal ItemDesc As String, ByVal UnitPrice As Decimal, ByVal Quantitiy As Integer, ByVal Discount As Decimal, ByVal LineTotal As Decimal)
        Me.m_ItemCode = ItemCode
        Me.m_ItemDesc = ItemDesc
        Me.m_UnitPrice = UnitPrice
        Me.m_Quantitiy = Quantitiy
        Me.m_Discount = Discount
        Me.m_LineTotal = LineTotal
    End Sub
'Property Get methods are there as well 
End Class
'Code Page
Protected ItemDetails As New ArrayList()
 Protected Sub btn_Add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Add.Click
End Sub
Private Function ItemDetailsCollection() As Boolean
        If ItemDetails.Add(New DisputeSalesItem(txt_ItemCode.Text.ToString, txt_ItemDesc.Text.ToString, Convert.ToDecimal(txt_UnitPrice.Text.ToString), CInt(txt_Quantity.Text), Convert.ToDecimal(txt_Discount.Text.ToString), Convert.ToDecimal(Convert.ToDecimal(txt_UnitPrice.Text.ToString) * CInt(txt_Quantity.Text) - Convert.ToDecimal(txt_Discount.Text.ToString)))) Then
            Return True
            Return False
        End If
End Function
Protected Sub BindItemDG()
        ItemDataGrid.DataSource = ItemDetails
        Table_DG.Visible = True
End Sub

Open in new window

Who is Participating?
Try this:
Insert after line #40:
Session("ItemDetails") = ItemDetails

Then add Page_Load event handler:
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not IsPostBack Then
    Me.ItemDetails = New ArrayList()
    Me.ItemDetails = Session("ItemDetails")
  End If
End Sub
But you have only added 1 item, which is on line #30.
If you try to call ItemDetailsCollection (line #25) twice, you'd see 2 items
AsishRajAuthor Commented:
Everytime user clicks add -> btn_Add_Click Sub is being called.

So user clicks add three times it will be called, the sub will be called three time and therefore i should have three rows in my arraylist but my datagrid only show one row.
AsishRajAuthor Commented:
Will work until i find a better Solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.