Donate

Show Processes From Your Computer Using ASP.NET Web Forms

Here's a sample code on how to display processes using Process.GetProcesses() method from Process class and bind it to the GridView Control.
Code behind:
protected void ShowProcessToGrid()  
{      
   Dictionary<string,string> process = new Dictionary<string,string>();  
   foreach(Process p in Process.GetProcesses())  
   {  
      process.Add(p.Id.ToString(),p.ProcessName);  
   }  
   this.gvPRocess.DataSource = process;  
   this.gvPRocess.DataBind();  
}  

protected void gvPRocess_PageIndexChanging(object sender, GridViewPageEventArgs e)  
{  
    gvPRocess.PageIndex = e.NewPageIndex;  
    ShowProcessToGrid();  
} 
Here is the aspx markup:
 <asp:GridView ID="gvPRocess" runat="server" AllowPaging="True"   
       BackColor="White" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"   
       CellPadding="4" style="margin:auto" AutoGenerateColumns="False"   
       onpageindexchanging="gvPRocess_PageIndexChanging">  
       <Columns>  
         <asp:BoundField DataField="Key" HeaderText="ID">  
         <ItemStyle Width="50px" />  
         </asp:BoundField>  
         <asp:BoundField DataField="Value" HeaderText="Name">  
         <ItemStyle Width="200px" />  
         </asp:BoundField>  
       </Columns>  
       <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />  
       <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />  
       <RowStyle BackColor="White" ForeColor="#003399" />  
       <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />  
       <SortedAscendingCellStyle BackColor="#EDF6F6" />  
       <SortedAscendingHeaderStyle BackColor="#0D4AC4" />  
       <SortedDescendingCellStyle BackColor="#D6DFDF" />  
       <SortedDescendingHeaderStyle BackColor="#002876" />  
     </asp:GridView>

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input