Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 21st, 2008, 12:05 PM
Registered User
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generic List bound to GridView

Hi there,
I have a little problem binding a 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

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
                Return vorname
            End Get
            Set(ByVal value As String)
                vorname = value
            End Set
        End Property
        Public Property GetPersNachname() As String
                Return nachname
            End Get
            Set(ByVal value As String)
                nachname = value
            End Set
        End Property
        Public Property GetPersAlter() As String
                Return alter
            End Get
            Set(ByVal value As String)
                alter = value
            End Set
        End Property
        Public Property GetPersGeburtsort() As String
                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

        GridView1.DataSource = p.lpers
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

    End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview bound dropdownlist edititemtemplate Bushwhacker ASP.NET 2.0 Basics 1 March 15th, 2008 07:35 PM
Generic List error ferahl C# 2 October 30th, 2007 03:28 AM
Sorting Gridview bound to strongly typed object kulkarnimonica ASP.NET 2.0 Professional 10 September 20th, 2007 03:32 PM
Generic Q on data bound program Minos Visual Basic 2005 Basics 1 November 9th, 2006 12:28 PM
paging a generic list trancehead ASP.NET 2.0 Professional 0 July 7th, 2006 03:39 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.