Using GridView and ObjectDataSource for Paging and Sorting#
I was scratching my head trying to figure out how to automagically sort and page through a dataset in asp.net 2.0 without having to write my own custom code like I used to have to in .net 1.1. In my code behind I was calling my business object and then setting the datasource properties in the Gridview. I could not get the sorting and paging to work. It was driving me crazy. Then I read that you need to set the DataSourceID property of the GridView to a sqldatasource or objectdatasource.

So I created an objectdatasource and pointed it to my business ojbect function that was doing the search and returning a dataset. I set the parameters of the ObjectDataSource to use QueryString and then everything worked fine.

I then was able to delete all of the code in my code behind. Amazing. You can actually implement a fully functional GridView without writing any code in a code-behind page. I love it.
Thursday, December 15, 2005 10:00:00 AM UTC #    Comments [1]  |  Trackback

 

Friday, June 20, 2008 7:49:06 PM UTC
Hmmpf. Depends on your definition for "fully" functional.

If you want to click on a link and return, having the original sort and position within pages persist: you're going to have to write code for page_load to prebind and then find the correct page.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, i, strong, u)  

Enter the code shown (prevents robots):

 

All content © 2009, Jim Zimmerman
Book
New Book
Links to me
On this page
Sponsors
Calendar
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Tags
Blogroll OPML
Technorati
Favorite Links
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail