Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding Datagrids to collection
Message
From
10/01/2007 20:17:49
 
 
To
10/01/2007 18:05:36
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01184397
Message ID:
01184426
Views:
18
Mike,

Did you try DataGrid1.Refresh()?

~~Bonnie



>I bound a datagrid to a collection class I created, and it works fine. Problem is, when I programatically add items to the collection, the datagrid does not reflect that. I tried to rebind the datagrid, but no dice. Any suggestions?
>
>
>    Public Class Recipients
>        Inherits CollectionBase
>
>        Public Sub New()
>
>            'var
>            Dim recipient As Recipient
>
>            Try
>                recipient = New Recipient("Mike", "1234", "Mike Inc.", "1234 5th St.", "Jesup", "IA", 50648)
>                innerlist.Add(recipient)
>
>                recipient = New Recipient("Joe", "4321", "Joe Inc.", "4321 1st St.", "Urbana", "IA", "55555")
>                innerlist.Add(recipient)
>
>                recipient = New Recipient("Herky", "5555", "Herky's Hawkeyes", "5555 5th St", "Iowa City", "IA", "54334")
>                innerList.Add(recipient)
>
>            Catch ex As Exception
>                Throw ex
>            End Try
>        End Sub
>
>        Public Sub Add(ByVal entry As Recipient)
>            InnerList.Add(entry)
>        End Sub
>
>        Public Sub Remove(ByVal index As Integer)
>            If index < 0 Or index > Me.Count - 1 Then
>                Throw New IndexOutOfRangeException
>            Else
>                InnerList.RemoveAt(index)
>            End If
>        End Sub
>
>        Default Public Property Item(ByVal index As Integer) As Recipient
>            Get
>                Return CType(InnerList.Item(index), Recipient)
>            End Get
>            Set(ByVal Value As Recipient)
>                InnerList.Item(index) = Value
>            End Set
>        End Property
>
>    End Class
>
>
>
> Dim searchColl As Recipients
> searchColl = New Recipients
> DataGrid1.DataSource = searchColl
> searchColl.Add(New Recipient("Mark", "8493", "asdf", "8848 1 St.", "Clear Lake", "IA", "50436"))
>
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform