We help IT Professionals succeed at work.
Get Started

Display list contents in gridview

Last Modified: 2012-05-12
I'm trying to get each list item into a table row and then bound to a gridview.

When i set a breakpoint at prefFlrIP = (From q In NewArray Select q) I can see the data i want displayed is present in prefFlrIP but only the first list item is displayed in my gridview.
Dim Table1 As DataTable
        Table1 = New DataTable("SnapDrivePrefIP")

        Dim PrefIP As DataColumn = New DataColumn("Preferred Filer/IP")
        PrefIP.DataType = System.Type.GetType("System.String")

        Dim Converter = Encoding.Convert(Encoding.Unicode, Encoding.Unicode, IO.File.ReadAllBytes(txtPath.Text & "\SnapDriveInfo\SnapDrive_RegistryInfo.log"))
        Dim ConvertedFile = System.Text.Encoding.Unicode.GetString(CType(Converter, Byte())).Split(vbCrLf)
        Dim sdRegistryData = (From j In ConvertedFile Where Not String.IsNullOrEmpty(j.Trim) Select j.Replace(" ", String.Empty).Trim).ToList

        Dim ReqCK = "[SYSTEM\CurrentControlSet\Services\SWSvc\Parameters\PreferredFilerIPAddresses]"
        Dim LastOC = "[SYSTEM\CurrentControlSet\Services\SWSvc\Parameters\Protocols]"
        Dim prefFlrIp As New List(Of String)

        If sdRegistryData.Contains(ReqCK) Then
            Dim NewArray As New List(Of String), StartLog As Boolean = False
            For Each x In sdRegistryData
                If x = LastOC Then Exit For
                If StartLog Then NewArray.Add(x)
                If x = ReqCK Then StartLog = True
            If NewArray.Count > 0 Then
                prefFlrIP = (From q In NewArray Select q).ToList
            End If

            Dim Row1 As DataRow
                Row1 = Table1.NewRow()

                Row1.Item(PrefIP) = If(prefFlrIp.Count > 0, prefFlrIp(0), "Not Set")

            Catch ex As Exception

            End Try
        End If

        gridPrefIP.DataSource = Table1

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE