Background
When an application is deployed onto the server and if at that time the application has some issues regarding security and other then at that time we have no mechanism to track the execution flow of ASP pages. So for knowing all the information we use Tracing.
Introduction to Tracing
Tracing is introduced in the .NET 2.0 version. Tracing helps to see the information of issues at the runtime of the application. By default Tracing is disabled.
Tracing has the following important features.
- We can see the execution path of the page and application using the debug statement.
- We can access and manipulate trace messages programmatically.
- We can see the most recent tracing of the data.
Tracing can be done with the following 2 types.
Page Level
When the trace output is displayed on the page and for the page-level tracing we need to set the property of tracing at the page level.
<%@ Page Trace="true" Language="C#" %>
Now I am explaining Tracing with an example.
Step 1. Open Visual Studio 2010.
Step 2. Then click on "New Project" > "Web" > "ASP.NET Empty Web Application".

Step 3. Now click on Solution Explorer and here click on "Add" > "New Item" > "Web Form" and add the name of the web form.

Step 4. Now in the web form take the grid view control and bind it with the database table.
<%@ Page Trace="true" Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Tracing.WebForm1" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
ForeColor="Black" GridLines="Vertical">
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</div>
</form>
</body>
</html>
Database table

Code behind
protected void Page_Load(object sender, EventArgs e)
{
// bind the grid view
// connection string
string con = "server=divs\\sqlexpress;database=pragim;uid=sa;password=divya";
SqlConnection con1 = new SqlConnection(con);
// write query
string query = "select * from student_info";
SqlDataAdapter da = new SqlDataAdapter(query, con1);
DataSet ds = new DataSet();
// fill in dataset
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}



Sandeep SiddhaparaPosted Jun 2, 2018, 8:52 AM
Nice post. Really helpful
Lakshmanan Sethu SankaranarayanPosted Jun 24, 2014, 1:53 AM
Thank you for sharing!
Saineshwar BageriPosted Jun 18, 2014, 11:58 PM
nice example