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

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - 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"];

}