Hi,
how are you exactly trying to do that. In my test I had a Datagrid
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:BoundColumn DataField="State" />
</Columns>
</asp:DataGrid>
I had a class MyState:
Public Class MyState
Private _abbreviation As String
Private _State As String
Public Sub New(ByVal abbreviation As String, ByVal state As String)
_abbreviation = abbreviation
_State = state
End Sub
Public ReadOnly Property Abbreviation() As String
Get
Return _abbreviation
End Get
End Property
Public ReadOnly Property State() As String
Get
Return _State
End Get
End Property
End Class
which was used with the grid:
Dim arrList As New ArrayList
arrList.Add(New MyState("A1", "1"))
arrList.Add(New MyState("A2", "2"))
arrList.Add(New MyState("A3", "3"))
DataGrid1.DataSource = arrList
DataGrid1.DataBind()
And it worked just fine.
Are you perhaps using C#? Have you make sure that it's not anything related
just to case-sensitivity, if you are?
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
[quoted text, click to view] "David H." <anonymous@discussions.microsoft.com> wrote in message
news:47364EEA-846E-4119-A683-DB3566231E18@microsoft.com...
I'm trying to bind an arraylist to a datagrid web control.
The arraylist contains "mystates" objects with properties named "state" and
"abbreviation."
I can set the grid's datasource to be the arraylist, but I am having trouble
referencing the properties of each arraylist item by their name. For
example, the grid doesn't like:
<asp:boundcolumn datafield="state" />
Is there an easy way around this?
Thanks!
- David H.