populating gridview using arraylist of structure

J

JayC

I am trying to understand how to use an arraylist that contains data in a
structure and bind the results to a gridview. Using vs2008

I have looked at the examples
315784 HOW TO: Bind a DataGrid Control to an Array of Objects or Structures by
http://support.microsoft.com/?id=315784

316302 HOW TO: Bind a DataGrid Control to an ArrayList of Objects or
Structures
http://support.microsoft.com/?id=316302

These examples are incomplete or are very confusing as they start out by
creating a class or stucture of guitar and then talk about currency something
in the end.

below is my sample code.

Public Structure userinfo
Dim sessionid As Integer
Dim servername As String
Dim appname As String
Dim sessionstate As String
Dim clientbuild As Integer
End Structure


Private Sub clickme_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles clickme.Click
Dim ss As MetaFrameSession
Dim username As String = "gbaham"
Dim sessionarray As userinfo
sessionarray = New userinfo
Dim sesslist As ArrayList
sesslist = New ArrayList
Dim state As String()
state = New String() {"Unknown", "Active", "Connected",
"Connecting", "Shadowing", "Disconnected", "Idle", "Listening", "Resetting",
"Down", "Init"}
For Each ss In thefarm.Sessions
If ss.UserName = username Then
sessionarray.sessionid = ss.SessionID
sessionarray.servername = ss.ServerName
sessionarray.appname = ss.AppName
sessionarray.sessionstate = state(ss.SessionState)
sessionarray.clientbuild = ss.ClientBuild
sesslist.Add(sesslist)
End If
Next
'this is where the data needs to be populated.
GridView1.DataSource = sesslist
GridView1.??????????
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top