• ASP.NET2.0 缓存(Cache)技术介绍


    觉得自定义控件中加入缓存,从而实现整个页的局部缓存,效果不错。

    自定义控件在前台加入:

    <%@ OutputCache Duration="60" VaryByParam="none" %>

    后台代码: 

       protected void Page_Load(object sender, EventArgs e)
        
    {
            Label1.Text 
    = DateTime.Now.ToString();

            source 
    = (DataView)Cache["SQUARE"];

            
    if (source == null)
            
    {
                conn 
    = new SqlConnection(ConfigurationManager.ConnectionStrings["GoConnectionString"].ConnectionString);
                mycmd 
    = new SqlDataAdapter("select * from GUser", conn);

                DataSet ds 
    = new DataSet();

                mycmd.Fill(ds, 
    "GUser");

                source 
    = new DataView(ds.Tables["GUser"]);

                Cache[
    "SQUARE"= source;

            }

            
    else 
            
    {
               
            }

            
            GridView1.DataSource 
    = source;
            GridView1.DataBind();
        }
  • 相关阅读:
    poj 1840 简单哈希
    poj 2151概率dp
    poj 3349 简单hash
    poj3274 hash
    poj 1459 最大流 Dinic模板题
    poj 3436 最大流-拆点
    poj 3020 二分图最大匹配
    poj 1094 简单拓扑排序
    poj3687 反向建图拓扑排序
    poj 3267
  • 原文地址:https://www.cnblogs.com/shengel/p/804116.html
Copyright © 2020-2023  润新知