Link to home
Start Free TrialLog in
Avatar of sivakugan
sivakugan

asked on

How to limit the display of records in Datalist?

Hi all,
I'm using Datalist. I want to limit the display of records. How can I do that?.
I mean if i wanna display only 10 records. What should I do for that?
Note- I'm not asking for paging in Datalist. I don't want that for my application.
Avatar of Amandeep Singh Bhullar
Amandeep Singh Bhullar
Flag of India image

You can achieve the task with the help of stored procedure.
It is much efficient and faster than gridview paging

Check the articles
http://www.codeproject.com/KB/webforms/GridViewCustomPaging.aspx
http://www.beansoftware.com/ASP.NET-Tutorials/Paging-Stored-Procedures.aspx

Hope this will help you
As per what i understand from your question is that you dont want paging. Then if you want to limit your dataset to 10 records with you want to populate your datalist, then i can suggest you one thing. Use the overloaded constructor of the dataadapter for getting only first 10 ten records or any 10 records you want. Have a look at the sample here:

http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcedataadapter.rowupdating(VS.80).aspx

Hope this helps you.
Avatar of sivakugan
sivakugan

ASKER

Hi KaushalArora,

If i wanna display 15 records in DESC order.  What should I do here?

DataSet ds = new DataSet();
   adp.Fill(ds, 0, 5, "Table");

ASKER CERTIFIED SOLUTION
Avatar of Kaushal Arora
Kaushal Arora
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Nice easy solution.