In the GridView area, put this in as

<asp:TemplateField HeaderText="Status" SortExpression="IP">
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("IP") %>'></asp:TextBox>
                    <asp:Image  ImageUrl='<%# getPing(DataBinder.Eval(Container.DataItem,"IP")) %>' runat="server" Width="30" >



On the aspx.cs area, put this in:


   Public Function getPing(ByVal sender As String) As String
        Dim pingSender As New Ping()
        Dim options As New PingOptions()

        ' Use the default Ttl value which is 128,
        ' but change the fragmentation behavior.
        options.DontFragment = True

        ' Create a buffer of 32 bytes of data to be transmitted.
        Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        Dim buffer() As Byte = Encoding.ASCII.GetBytes(data)
        Dim timeout As Integer = 1200
        Dim reply As PingReply = pingSender.Send(Trim(sender), timeout, buffer, options)
        If reply.Status = IPStatus.Success Then
            Return "true.png"
            Return "false.png"

        End If

    End Function


As you can see, the field will show a result returned from the VB method as a png.


About Lei

I am an IT specialist with over 10 year experience - years on Automation, on-Premise or Azure.

I am happy to develop however never want be a full time developer. Only do what I have to do. If it has to be PowerShell,HTML, PHP, CSS, C#, VBS or JS, front end or backend, so be it, doesn't matter!

Spent years with Windows, SCCM, SharePoint, SQL and Exchange servers. For last several years, I have been actively working under On Premise > Azure environment.


Current Certificates:
    Microsoft® Certified-
  • -Enterprise Administrator
  • -Database Administrator
  • -SharePoint Administrator
  • -Administering and Deploying SCCM 2012
Red Hat Certified Technician
ITIL V3 Foundation - Practitioner

Working on Azure Certificates now and hopefully they can stop upgrading their questions one day! GIVE ME A BREAK!

Contact Lei

Name *
Email *
Comments *

Traffic since 10/08/2016

This week13
This month2086

Visitor Info

  • IP:
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online