打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Using SPGridView to Display Your Data in WSS 3.0
Using SPGridView to Display Your Data in WSS 3.0

The other day I went to visit one of my colleagues in the building I currently work at. Was talking to him and noticed that he was using the SPGridView control to render his data, so thought of using it instead of using the ASP.NET data grid and then spend a lot of time trying to make look like SharePoint!

So as usual, the first thing I do; tried to Google it, the disappointment was that I only found two good posts on the web (One by Paolo and the other is by Bob). That being said; I had to take the challenge and create my own version of the SPGridView. Plus the SPGridView gives you the ability to create list item menus that are like the one that is available with the out of the box list views.

So let us get started!

Features available with my version of SPGridView:

  • Sorting.
  • Grouping.
  • Filtering.
  • Paging.

Going through the blog posts, I found out that SPGridView had some trouble remembering user selection when two operations are applied on the SPGridView at the same time (for example: sorting and filtering, paging and sorting … etc.) and that the developer has to manually store some information in the View State object to make it remember things.

So imagine, every time you want to use the SPGridView, you will have to remember all the details of how to make SPGridView remember its state? Plus more!

First idea came to my mind was to create a new class that inherits the SPGridView (I was lucky it was not sealedJ) and encapsulate all the "remembering" abilities inside of it, this way we leave the developer away from the details of how to handle it.

I am not going to go through the details of what all things mean since Paolo and Bob did a wonderful job explaining it all.

Click here to get the code for the SWSSPGridView that I have implemented.

Now, to test that class, I need to create a ExampleObjectDataSource and a WebPart that will hold the SWSSPGridView.

Click here for the code for the ExampleObjectDataSource.

Click here for the code for the WebPart that will hold our SWSSPGridView.

Deploy the WebPart to your SharePoint environment and add it to a page, you should get the following display.

And now our SWSSPGridView is aware of the user selection and keeps track of it without making the developer worry about how to do it!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
观点 | Web 3.0将为元宇宙的发展提供底层基础 | 巴比特
生活希望我们学会的50条人生道理
网易公开课幸福课笔记
10 Ways To Create Content For Your Weblog
TED学院 | 快乐藏在哪里?我们如何寻找它?
21 Things You Didn't Know Your iPhone Could Do
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服