惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - bluehat

如果你的sharepoint 2013很慢... Sharepoint 2010 Timer Job 自定义开发的几个注意事项 2011你教会我的那些事儿 【sharepoint】SPEventReceiverStatus.CancelWithRedirectUrl 出错的请看这里 SharePoint Server 2010 LDAP Form 验证最容易出错的几点 CRM 客户端 SharePoint 2010 中如何彻底删除用户 Sharepoint 2010 中配置同步连接报错. - bluehat Exchange 2007 内存使用问题 不是黄山,胜似黄山--端午节之旅 心情不错 纠结 炎炎夏日,无心... 我想做一个有故事的人 无意发现Win 7 的时钟小秘密 小兽... 游陈阁老故乡 I am lost [ZZ]5 Paths to Happiness
SharePoint 2007/2010 的"SPGridView "控件常见的两个问题
bluehat · 2010-10-22 · via 博客园 - bluehat

大家在使用SharePoint 2007或者 SharePoint 2010 里的SPGridView 的时候,可能会遇到两个问题。

问题一:无法显示分页的页码。

很多朋友很奇怪明明已经设置如下的代码

oGrid.AllowPaging = true;
oGrid.PageSize = 2;
oGrid.PageIndexChanging +=new GridViewPageEventHandler(oGrid_PageIndexChanging);

但是页面上无法显示页码。

这个是SharePoint 自己的问题,我们需要加入下面一行代码

Controls.Add(oGrid);
oGrid.PagerTemplate = null;//这行就是要加的代码,顺序很重要,一定要在Controls.Add之后,DataBind();之前
oGrid.DataBind();

现在再试试,是不是就可以看见页码了^_^

问题二:启用了过滤后,在翻页以后,发现在选择下一页,SPGridView会加载所有的数据,而不是filter过滤的数据。过滤功能失效了。

因为在render 下一页后,无法继续保存filter .所以这里有这样一个办法大家可以试试:

首先在OnPreRender里插入下面代码保存FilterExpression 到ViewState中,(记得确保代码里Enable ViewState)

protected override void OnPreRender(EventArgs e) {

ViewState["FilterExpression"] = odsDataSource.FilterExpression;

base.OnPreRender(e);

}

然后

在您的Controls.Add(odsDataSource); 之前插入下面的代码,

HttpRequest req = HttpContext.Current.Request; if (req.Form["__CALLBACKID"] == null ||

req.Form["__CALLBACKPARAM"] == null ||

!req.Form["__CALLBACKID"].EndsWith("ExampleGrid"))

{

if (ViewState["FilterExpression"] != null)

odsDataSource.FilterExpression = (string)ViewState["FilterExpression"];

}