【发布时间】:2015-08-19 13:10:58
【问题描述】:
我的页面上几乎没有 Gridview。数据源必须在页面打开时运行,所以我不能对整个页面使用 OutputCache。
但是 1 Gridview 并不重要,查询也很慢。这就是为什么我需要缓存它。 1 小时/1 次查询对我来说很好。
我的连接:
try
{
OleDbConnection Connection1;
using (Connection1 = new OleDbConnection("Provider=MSDAORA.1;Data Source=DATABASE:1521/orcl;Persist Security Info=True;Password=PASSWORD;User ID=USERNAME;"))
{
string sqlQuery = "select * from TABLE";
using (OleDbDataAdapter cmd = new OleDbDataAdapter(sqlQuery, Connection1))
{
Connection1.Open();
DataTable dt = new DataTable();
cmd.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
Connection1.Close();
}
}
}
catch (Exception)
{
}
如何只缓存 1 个连接?
我可以只为 1 个 Gridview 使用 OutputCache 吗?
我需要从连接端缓存吗?
【问题讨论】:
-
把你的gridview放到用户控件中并缓存用户控件
-
你能给我举个例子吗?谢谢。
标签: c# asp.net gridview outputcache oledbconnection