Web Services .NET Grid: Retrieve Data and Show to Data Grid



Web Services PHP - Grid .NET Step By Step Tutorial - Part 6: Last, we will add code for button. When use click button, it retrieve data from server then display to datagrid.

First, create a class named "test_book". You can add item from menu bar: Project > Add Class. Enter name "test_book.vb". Then enter this code:

Public Class test_book

    Private _id As Integer
    Private _title As String
    Private _author As String

    Public Sub New(ByVal id As Integer, ByVal title As String, ByVal author As String)
        _id = id
        _title = title
        _author = author
    End Sub

    Public ReadOnly Property id() As Integer
        Get
            Return _id
        End Get
    End Property

    Public ReadOnly Property title() As String
        Get
            Return _title
        End Get
    End Property

    Public ReadOnly Property author() As String
        Get
            Return _author
        End Get
    End Property

    Public Overloads Overrides Function ToString() As String
        Return String.Format("{0}#{1}#{2}", _id, _title, _author)
    End Function

End Class

Next, Double click on button. Then enter following code:

        Dim arl As New ArrayList
        Dim ws As New library.LibraryService
        Dim str As String = ws.doLibrary("")

        'split each row into array
        Dim arr As Array = str.Split("#")
        Dim book(3) As String

        For Each item As Object In arr
            If item <> Nothing Then
                'split each item
                book = Convert.ToString(item).Split("|")
                arl.Add(New test_book(book(0), book(1), book(2)))
            End If
        Next


        DataGrid1.DataSource = arl
        DataGrid1.Refresh()

Now, try to test it.



Series this article:
Web Services .NET Grid: Create WSDL Document
Web Services .NET Grid: Preparing Database
Web Services .NET Grid: Create SOAP Server
Web Services .NET Grid: Testing with SOAP client
Web Services .NET Grid: Creating User Interface for VB.NET
Web Services .NET Grid: Retrieve Data and Show to Data Grid


Tag: web services, .net, vb.net, grid Category: PHP Application Post : April 15th 2008 Read: 1,699 Bookmark and Share

blog comments powered by Disqus