serkan sendur 821 Postaholic Banned Featured Poster

Create a Web form :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WorkerProcessInfo.aspx.cs" Inherits="WorkerProcessInfo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WorkerProcessInfo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager runat="server" ID="scrpt"></asp:ScriptManager>
    <asp:UpdateProgress runat="server" ID="uptPrg" AssociatedUpdatePanelID="upt">
    <ProgressTemplate>
    Loading...
    </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel runat="server" ID="upt">
    <ContentTemplate>

        <asp:GridView AutoGenerateColumns="false" ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="20" Height="650px" Width="600px" EnableViewState="False">
            <Columns>
            <asp:TemplateField>
            <HeaderTemplate>
            Name
            </HeaderTemplate>
            <ItemTemplate>
            <%# Eval("property") %>
            </ItemTemplate>
            <ItemStyle Width="50%" />
            </asp:TemplateField>
             <asp:TemplateField>
             <HeaderTemplate>
            Value
            </HeaderTemplate>
            <ItemTemplate>
            <%# Eval("value") %>
            </ItemTemplate>
             <ItemStyle Width="50%" />
            </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <EditRowStyle BackColor="#999999" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>

        </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

The CodeBehind of the form will be this :

using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Reflection;

public partial class WorkerProcessInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            fillGrid();
        }

    }

    private void fillGrid()
    {
        Process p = Process.GetCurrentProcess();
        DataTable dt = new DataTable();
        dt.Columns.Add("property");
        dt.Columns.Add("value");
        foreach (System.Reflection.PropertyInfo prop in p.GetType().GetProperties())
        {

            try
            {
                dt.Rows.Add(new object[] { prop.Name, prop.GetValue(p, null).ToString() });

            }
            catch
            {
                dt.Rows.Add(new object[] { prop.Name, "null" });
            }


        }
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        fillGrid();
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.