OutPutCacheByPrameter.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OutPutCacheByPrameter.aspx.cs" Inherits="OutPutCacheByPrameter" %>
<!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>Caching; Varying the Output Cache By Parameter</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="grdEmployee" runat="server" AutoGenerateColumns="False"
ShowHeader="False">
<Columns>
<asp:HyperLinkField DataTextField="EmpName" DataNavigateUrlFields="EmpId"
DataNavigateUrlFormatString="EmployeeDetails.aspx?EmpId={0}" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
Code File:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class OutPutCacheByPrameter : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter da;
protected void Page_Load(object sender, EventArgs e)
{
BindData();
}
public void BindData()
{
string Appcon = ConfigurationManager.ConnectionStrings["ConnectionStr"].ConnectionString;
con = new SqlConnection(Appcon);
cmd.CommandText = "Select * from Employees";
da = new SqlDataAdapter(cmd);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
grdEmployee.DataSource = ds;
grdEmployee.DataBind();
}
}
}
web.config:
<connectionStrings>
<add name="ConnectionStr" connectionString="Data Source=.;Initial Catalog=asp;User Id=sa;Password=niitbpl123"/>
</connectionStrings>
Code Behind File:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class OutPutCacheByPrameter : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter da;
protected void Page_Load(object sender, EventArgs e)
{
BindData();
}
public void BindData()
{
string Appcon = ConfigurationManager.ConnectionStrings["ConnectionStr"].ConnectionString;
con = new SqlConnection(Appcon);
cmd.CommandText = "Select * from Employees";
da = new SqlDataAdapter(cmd);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
grdEmployee.DataSource = ds;
grdEmployee.DataBind();
}
}
}
EmployeeDetails.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EmployeeDetails.aspx.cs" Inherits="EmployeeDetails" %>
<%@ OutputCache Duration="5" VaryByParam="none" %>
<!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>CACHING: Output Cache By Parameter: Employee Details</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblTime" runat="server"></asp:Label><br />
<br />
<asp:DetailsView ID="dtlEmployee" runat="server">
</asp:DetailsView>
</div>
</form>
</body>
</html>
Code Behind File:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class EmployeeDetails : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter da;
protected void Page_Load(object sender, EventArgs e)
{
lblTime.Text = System.DateTime.Now.ToString();
BindData();
}
public void BindData()
{
string Appcon = ConfigurationManager.ConnectionStrings["ConnectionStr"].ConnectionString;
con = new SqlConnection(Appcon);
cmd.CommandText = "Select * from Employees where EmpId=" + Request.Params[0].ToString();
da = new SqlDataAdapter(cmd);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
dtlEmployee.DataSource = ds;
dtlEmployee.DataBind();
}
}
}
Output:
We provide personal finances for debt consolidation, bad credit finances, unsecured finances, finances for bad credit and instant secured finances with cheap rates. Do you have a firm or company that need finance to start up a business or need,personal finance, Debt consolidation? For more information. We will provide you with finance to meet your needs. For more information contact.
ReplyDeleteWe offer Easy and Fast Credit facility.
Email: royalworldfundings@gmail.com
Note: We offer the following finances to individuals-
Commercial finances
Personal finances
Business finances
Investments finances
Development finances
Acquisition finances
Construction finances
Business finances And many More at 3% interest rate;
Contact Us At : royalworldfundings@gmail.com
If you had financial problems, then it is time for you to smile. You only need to contact Mr. Benjamin with the amount you wish to borrow and the payment period that suits you and you will have your loan within three working days. I just benefited for the sixth time a loan of 700 thousand dollars for a period of 180 months with the possibility of paying before the expiration date. Mr Benjamin has be helping me with loan.Make contact with him and you will see that he is a very honest man with a good heart.His email is lfdsloans@lemeridianfds.com and his WhatApp phone number is + 1-989-394-3740
ReplyDelete