populating gridview using arraylist of structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SmF5Qw==?=

    #1

    populating gridview using arraylist of structure

    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(B yVal sender As Object, ByVal e As
    System.EventArg s) Handles clickme.Click
    Dim ss As MetaFrameSessio n
    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" , "Disconnect ed", "Idle", "Listening" , "Resetting" ,
    "Down", "Init"}
    For Each ss In thefarm.Session s
    If ss.UserName = username Then
    sessionarray.se ssionid = ss.SessionID
    sessionarray.se rvername = ss.ServerName
    sessionarray.ap pname = ss.AppName
    sessionarray.se ssionstate = state(ss.Sessio nState)
    sessionarray.cl ientbuild = ss.ClientBuild
    sesslist.Add(se sslist)
    End If
    Next
    'this is where the data needs to be populated.
    GridView1.DataS ource = sesslist
    GridView1.????? ?????
    End Sub





  • Cor Ligthert[MVP]

    #2
    Re: populating gridview using arraylist of structure

    Jay,

    Don't assume that the DataGrid or DataGridView is the same as a GridView, it
    is as equal with that as a plane to a car.

    I think that you find on the page bellow enough to reach your goal.

    http://msdn2.microsoft.com/en-us/library/ms752213.aspx

    Cor

    Comment

    Working...