在DataGrid分页时需要重新装载数据吗? DataGrid 本身并不能进行任何减少数据流量的操作,只不过是将取得的一部分数据隐藏了而已。在效率上没有任何改观 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如何把DateSet对象加入到缓存中, 在第一次取得数据源时,调用Cache.Add()方法把数据源加入缓存中,注意key的生成和数据源的生存期。翻页时直接从Cache["xxxxx"]中取得数据源,与grid绑定 建议用SQL分页,速度特快(每次只取十条记录) :( 我很菜Cache.Add(...)和Cache["xxxxx"]中间该怎么写,请举个简单的例子 private void Page_Load(object sender, System.EventArgs e){DataSet myds = DataSet(Cache.item("dsNotify"))if (myds==null){SqlConnection mycon =new SqlConnection ("Server=.;Database=estate;user id=sa;password=sql"); SqlDataAdapter myda = new SqlDataAdapter ("select * from notify",mycon);myds = new DataSet();myda.Fill (myds,"notify");//把myds存入cacheCache.insert("dsNotify",myds,Nothing, _ DateTime.Now.AddHours(1), Cache.NoSlidingExpiration)}this.DataGrid1 .DataSource =myds .Tables ["notify"];this.DataGrid1 .DataBind ();} 上面的DataSet myds = DataSet(Cache.item("dsNotify"))应该改为DataSet myds = DataSet(Cache.item["dsNotify"])呵呵,用vb用惯了,不习惯c#的语法 怪,Cache中没有item属性啊,我用VS.net2003 C#,WebForm中 抱歉,我用的vb,没试一下就直接发上来了,在c#中应该直接使用Cache["dsNotfy"],把myds存入cache应该用Cache.Insert("","",null,DateTime.Now.AddHours(1),Cache.NoSlidingExpiration); :(上面又写错了,是Cache.Insert("dsNotify",myds,null,DateTime.Now.AddHours(1),Cache.NoSlidingExpiration); 可以了,直接用this.Cache["myds"]就可以了还想问一下缓存是在本机还是在服务器 如果数据量不大,还是不用缓存比较好。重新bind并不会浪费明显的时间的。 如何 实现如彩票开奖数据折线图这样的图标? 能从c#的浏览器组件提取response中的body吗? 面向对象的编程,关c#比较经典的,高手推荐一下。 调用addrow时候老是说对象未引用???? 数据结构和算法 这个特性怎么用啊!谢谢帮忙看看! EF 怎么获取关联表的数据? winform下如何做成如图那样的表格 dataGrid保存时的问题(在线等) 事件??? 如何在DataGrid中的CheckBox中只能有一个CheckBox选中? 大虾,请指教!
我很菜Cache.Add(...)和Cache["xxxxx"]中间该怎么写,请举个简单的例子
{DataSet myds = DataSet(Cache.item("dsNotify"))
if (myds==null)
{
SqlConnection mycon =new SqlConnection ("Server=.;Database=estate;user id=sa;password=sql"); SqlDataAdapter myda = new SqlDataAdapter ("select * from notify",mycon);myds = new DataSet();myda.Fill (myds,"notify");//把myds存入cache
Cache.insert("dsNotify",myds,Nothing, _
DateTime.Now.AddHours(1), Cache.NoSlidingExpiration)
}this.DataGrid1 .DataSource =myds .Tables ["notify"];
this.DataGrid1 .DataBind ();
}
DataSet myds = DataSet(Cache.item["dsNotify"])
呵呵,用vb用惯了,不习惯c#的语法
Cache.Insert("","",null,DateTime.Now.AddHours(1),Cache.NoSlidingExpiration);
Cache.Insert("dsNotify",myds,null,DateTime.Now.AddHours(1),Cache.NoSlidingExpiration);
还想问一下缓存是在本机还是在服务器