p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Datalist Paging (http://p2p.wrox.com/showthread.php?t=60971)

nedo_786 August 9th, 2007 03:14 AM

Datalist Paging
I am working on a webapplication.Search results return thousands of records.I am using datalist(asp.net2.0) to display results.
But I amazed that datalist does not provide built in paging facility as other controls like gridview,detailsview and formview.
Please give me some solution to achieve this without using heavy code.Thanks

gaurav_jain2403 August 9th, 2007 08:24 AM

You are refraining from using heavy code. But, not to disappoint you, achieving paging in datalist require hard work from you. You have to maintain few things in ViewState variable like the current page index, size of page(optional). You will have to check the number of rows returned by your query and accordingly, you will have to display that many links in footer. Also, You can add Four buttons in the footer i.e. First, Last, Next, Previous.

The other important thing is that you should always update the viewstate variable smartly. Use SqlDataAdapter1.Fill(DataSet1,startIndex,PageSize, "TableName"); to fill your dataset and bind that dataset to your datalist.

This is the logic you have to use. You can also search google, you will find source code there.

nedo_786 August 9th, 2007 09:07 AM

Thanks dear!
But I want some simpler solution,As I already searched a lot and that all provide same solution.
I am working on solution myself, and Inshallah I'll provide you people most simpler solution very soon.

dparsons August 9th, 2007 09:18 AM

The only way i see for you to come up with a "simpler" solution is to create a control that inherits from the datalist control and then provide support for paging within the control itself. This would then give your control a behavior much like that of GridView where we just need to call NewPageIndex. Of course, this isn't necessary simpler, it is just a control that supports paging.

Good luck.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========

planoie August 9th, 2007 02:36 PM


Are you not able to use the GridView control for some reason? That would give you built in paging without "heavy code".


nedo_786 August 10th, 2007 02:45 AM

I know that gridview offer strait way for paging,But that does not fullfill my formating requirements.Anyway thanks for contribution.

gbianchi August 10th, 2007 07:32 AM

are you sure about that?? you can do almost anything with a gridview...



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========

planoie August 10th, 2007 08:51 AM

Please provide an example of how you wish to format the data. It is very likely that you can do it with the GridView. I think about the ONLY restriction that you'll face is that the data will be presented in a top-down tabular style.

By turning off all the extra parts of the grid view (borders, headers, footers, etc.) and using a single column you can format it as you like and make it display just like a list format.


nedo_786 August 11th, 2007 05:09 AM

Thanks that solutions works for me
Really thankfull to you!

Namrata September 20th, 2007 04:32 AM

Hey guys, I want to share my problem.. My problem is that the columns displayed in gridview are top down.. I hav a single image column which I want in 4*4 matrix format..Plz help me out..

I tried with Datalist.. but as u said it requires a heavy code and I am nt able to achieve wid it..!!! Plz help me out soon..

All times are GMT -4. The time now is 11:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.