I have a gridview, where i loaded some 1000's of records with pageing.
so when ever i click on the page numbers its just moveing to the corresponding page records.
Hence, from above work, i have fetched all 1000 records in a single DB hit and makeing pageing. so pageing is created automatically by gridview.
Suppose if i need like below senario
i.e i need to fetch datas from DB when ever i change pageing. If i fetch 20 records first time the grid sows datas, but i cant see pageing.
how couldi do this...?
So, i need pageing, and when the pageing changes the datas should fetch from DB. so intially i will fetch only 20 records out of 1000(even in upcoming DB fetches also)
Plz share the thoughts and solutions..
If you win, you need not have to explain...If you lose, you should not be there to explain!
So, i need pageing, and when the pageing changes the datas should fetch from DB. so intially i will fetch only 20 records out of 1000(even in upcoming DB fetches also)
.skip(20).take(20) then the gridview will display records from 21 to 30 (app...), but i cant see pageing in gridview..now how can i go to 3rd page now...
Is it possible to keep pageing in gridview or i need to do some customtemplate for that
If you win, you need not have to explain...If you lose, you should not be there to explain!
shree_ars
Participant
1395 Points
776 Posts
Pageing in Gridview
Apr 26, 2012 10:39 AM|LINK
Hi all,
I need some clarification on pageing.
Right now i am doing,
I have a gridview, where i loaded some 1000's of records with pageing.
so when ever i click on the page numbers its just moveing to the corresponding page records.
Hence, from above work, i have fetched all 1000 records in a single DB hit and makeing pageing. so pageing is created automatically by gridview.
Suppose if i need like below senario
i.e i need to fetch datas from DB when ever i change pageing. If i fetch 20 records first time the grid sows datas, but i cant see pageing.
how couldi do this...?
So, i need pageing, and when the pageing changes the datas should fetch from DB. so intially i will fetch only 20 records out of 1000(even in upcoming DB fetches also)
Plz share the thoughts and solutions..
prajapatiami...
Member
548 Points
395 Posts
Re: Pageing in Gridview
Apr 26, 2012 10:42 AM|LINK
Hi
Please use skip and Take using Linq
example
EmployeeInfoDataContext dbEmp = new EmployeeInfoDataContext();
var query = from emp in dbEmp.Employees
join dept in dbEmp.Departments
on emp.DeptID equals dept.DeptID
select new
{
EmpID = emp.EmpID,
EmpName = emp.EmpName,
Age = emp.Age,
Address = emp.Address,
DeptName = dept.DepartmentName
};
return query.Skip(startRowIndex).Take(maximumRows);
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
kedarrkulkar...
All-Star
35563 Points
5700 Posts
Re: Pageing in Gridview
Apr 26, 2012 10:45 AM|LINK
your thinking on right way..
refer these for more info
http://www.4microsoftsolutions.com/post/Paging-in-GridviewCustom-Paging-Of-Large-Record-Set-in-ASPNET.aspx
http://www.codeproject.com/Articles/125541/Effective-Paging-with-GridView-Control-in-ASP-NET
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
shree_ars
Participant
1395 Points
776 Posts
Re: Pageing in Gridview
Apr 26, 2012 10:55 AM|LINK
dudes..thks
actually i tried using skip and take in linq..
so what happeing is...
If i use like this
.skip(20).take(20) then the gridview will display records from 21 to 30 (app...), but i cant see pageing in gridview..now how can i go to 3rd page now...
Is it possible to keep pageing in gridview or i need to do some customtemplate for that
prajapatiami...
Member
548 Points
395 Posts
Re: Pageing in Gridview
Apr 26, 2012 11:08 AM|LINK
Hi please check below url
http://www.codedigest.com/Articles/ASPNET/153_Custom_Paging_for_GridView_using_LINQ.aspx
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
shree_ars
Participant
1395 Points
776 Posts
Re: Pageing in Gridview
May 03, 2012 03:52 AM|LINK
Pageing is possible only in case of full fetched data from server.
If server post back for each page index then.. custom or usercontrol pageindex need to be designed and controlled.