AsishRaj
asked on
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
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
ItemDetailsCollection()
BindItemDG()
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
Else
Return False
End If
End Function
Protected Sub BindItemDG()
ItemDataGrid.DataSource = ItemDetails
ItemDataGrid.DataBind()
Table_DG.Visible = True
End Sub
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Will work until i find a better Solution
If you try to call ItemDetailsCollection (line #25) twice, you'd see 2 items