Board index » Visual Studio » populating gridview using arraylist of structure
|
KeithSea
|
populating gridview using arraylist of structure
Visual Studio220
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 support.microsoft.com/ 316302 HOW TO: Bind a DataGrid Control to an ArrayList of Objects or Structures support.microsoft.com/ 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 - |
