A
Andreas Hartje
Hi there,
sorry for crossposting, it's getting late in the evening here in Europe :-(
I have a little problem binding a generic list to a GridView. The List gets
filled
with data from textboxes (via properties in class Person, see below) and I
want the grid to show each new set of textbox strings to show up as a new
row in the grid. i mahaged to do this by definig a little sessionmanagement
but the really problem now is that each time I post the strings to the
server, the previus set of data/strings in my grid (and also in the List)
gets overritten with the last input of strings. In the end i get thre or
four or more rows in my dataset with the strings of the textbox input.
Any idea about this?
Thanks very much, Andi
CODE:
Public Class Person
Public lpers As New List(Of Person)
Private vorname As String
Private nachname As String
Private alter As String
Private geburtsort As String
Public Property GetPersVorname() As String
Get
Return vorname
End Get
Set(ByVal value As String)
vorname = value
End Set
End Property
Public Property GetPersNachname() As String
Get
Return nachname
End Get
Set(ByVal value As String)
nachname = value
End Set
End Property
Public Property GetPersAlter() As String
Get
Return alter
End Get
Set(ByVal value As String)
alter = value
End Set
End Property
Public Property GetPersGeburtsort() As String
Get
Return geburtsort
End Get
Set(ByVal value As String)
geburtsort = value
End Set
End Property
End Class
Dim p As New Person
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If IsNothing(Session("Person")) Then
Session("Person") = New Person
End If
p = Session("Person")
End Sub
Public Sub arrFill()
p.GetPersVorname = TextBox1.Text
p.GetPersNachname = TextBox2.Text
p.GetPersAlter = TextBox3.Text
p.GetPersGeburtsort = TextBox4.Text
p.lpers.Add(p)
GridView1.DataSource = p.lpers
GridView1.DataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
arrFill()
End Sub
sorry for crossposting, it's getting late in the evening here in Europe :-(
I have a little problem binding a generic list to a GridView. The List gets
filled
with data from textboxes (via properties in class Person, see below) and I
want the grid to show each new set of textbox strings to show up as a new
row in the grid. i mahaged to do this by definig a little sessionmanagement
but the really problem now is that each time I post the strings to the
server, the previus set of data/strings in my grid (and also in the List)
gets overritten with the last input of strings. In the end i get thre or
four or more rows in my dataset with the strings of the textbox input.
Any idea about this?
Thanks very much, Andi
CODE:
Public Class Person
Public lpers As New List(Of Person)
Private vorname As String
Private nachname As String
Private alter As String
Private geburtsort As String
Public Property GetPersVorname() As String
Get
Return vorname
End Get
Set(ByVal value As String)
vorname = value
End Set
End Property
Public Property GetPersNachname() As String
Get
Return nachname
End Get
Set(ByVal value As String)
nachname = value
End Set
End Property
Public Property GetPersAlter() As String
Get
Return alter
End Get
Set(ByVal value As String)
alter = value
End Set
End Property
Public Property GetPersGeburtsort() As String
Get
Return geburtsort
End Get
Set(ByVal value As String)
geburtsort = value
End Set
End Property
End Class
Dim p As New Person
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If IsNothing(Session("Person")) Then
Session("Person") = New Person
End If
p = Session("Person")
End Sub
Public Sub arrFill()
p.GetPersVorname = TextBox1.Text
p.GetPersNachname = TextBox2.Text
p.GetPersAlter = TextBox3.Text
p.GetPersGeburtsort = TextBox4.Text
p.lpers.Add(p)
GridView1.DataSource = p.lpers
GridView1.DataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
arrFill()
End Sub