zkusil jsem tohle, pocet itemu narusta, ale kazdy ma hodnoty toho posledniho
Partial Class _Default
Inherits System.Web.UI.Page
<Serializable()>
Public Class Product
Shared Property Material As String
Shared Property Type As String
Shared Property ImageURL As String
End Class
Public Property CurrentSelection() As Product
Get
Dim text As Product = ViewState("Product")
If text IsNot Nothing Then
Return text
Else
Dim Ntext As New Product
ViewState("Product") = Ntext
Return Ntext
End If
End Get
Set(ByVal value As Product)
ViewState("Product") = value
End Set
End Property
Public Property Products() As List(Of Product)
Get
Dim text As List(Of Product) = ViewState("Products")
If text IsNot Nothing Then
Return text
Else
Dim Ntext As New List(Of Product)
ViewState("Products") = Ntext
Return Ntext
End If
End Get
Set(ByVal value As List(Of Product))
ViewState("Products") = value
End Set
End Property
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim First As New Product
First.Material = "1111"
First.Type = ""
First.ImageURL = ""
Products.Add(First)
For Each item In Products
Response.Write(item.Material & "</br>")
Next
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Second As New Product
Second.Material = "2222"
Second.Type = ""
Second.ImageURL = ""
Products.Add(Second)
For Each item In Products
Response.Write(item.Material & "</br>")
Next
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim Third As New Product
Third.Material = "3333"
Third.Type = ""
Third.ImageURL = ""
Products.Add(Third)
For Each item In Products
Response.Write(item.Material & "</br>")
Next
End Sub
End Class