Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts


Imports System.Diagnostics
Imports Telerik.Web.UI

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Dim filterOption As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        filterOption = String.Empty

    End Sub

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource

        Dim processList As IEnumerable

        processList = From p In Process.GetProcesses() Where (String.Equals(p.ProcessName, filterOption)) Select New With {.ID = p.Id, .Name = p.ProcessName}
        

        If Not String.Equals(filterOption, String.Empty) Then

            processList = From p In Process.GetProcesses() Where (String.Equals(p.ProcessName, filterOption)) Select New With {.ID = p.Id, .Name = p.ProcessName}
        Else

            processList = From p In Process.GetProcesses() Select New With {.ID = p.Id, .Name = p.ProcessName}
        End If

            RadGrid1.DataSource = processList

    End Sub

    Protected Sub RadScriptManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadScriptManager1.AjaxRequest

        If e.Argument.StartsWith("Filter") Then
            RadScriptManager1.AjaxSettings.AddAjaxSetting(RadScriptManager1, RadGrid1)
            filterOption = e.Argument.Replace("Filter:", String.Empty)

            RadGrid1.Rebind()
        End If

    End Sub
End Class