Tuesday, February 21, 2012

Show processes in ur pc using asp.net

Code behind:
Code:
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>  

0 comments:

Post a Comment