转发器控件中的自定义分页,而不是在c#.net中使用pagedatasource? [英] custom paging in repeater control with out using pagedatasource in c#.net?
问题描述
我想实现自定义分页(第一个,下一个,上一个,最后一个),没有链接按钮,而不使用c#.net中的转发器控制中的pagedatasource?
请参阅以下链接....
http://www.aspsnippets.com/Articles/Custom-Paging-in-ASP.Net-GridView-using -SQL-Server-Stored-Procedure.aspx
来自他们正在使用的上述链接 populatepager function pls通过添加next和以前的逻辑...请帮我...
i want to implement custom paging(first,next,previous,last)with out link buttons and without using pagedatasource in repeater control in c#.net?
pls see the below link....
http://www.aspsnippets.com/Articles/Custom-Paging-in-ASP.Net-GridView-using-SQL-Server-Stored-Procedure.aspx
from the above link they are using populatepager function pls modify that function by adding next and previous logic ...pls help me out...
private void PopulatePager(int recordCount, int currentPage)
{
double dblPageCount = (double)((decimal)recordCount / decimal.Parse(ddlPageSize.SelectedValue));
int pageCount = (int)Math.Ceiling(dblPageCount);
List<ListItem> pages = new List<ListItem>();
if (pageCount > 0)
{
pages.Add(new ListItem("First", "1", currentPage > 1));
for (int i = 1; i <= pageCount; i++)
{
pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
}
pages.Add(new ListItem("Last", pageCount.ToString(), currentPage < pageCount));
}
rptPager.DataSource = pages;
rptPager.DataBind();
}
我用以下格式修改了我的代码页面大小5 ...我的下一个和上一个逻辑不起作用
i modified my code in below format with page size "5"...my next and previous logic is not working
private void PopulatePager(int recordCount, int currentPage)
{
double dblPageCount = (double)((decimal)recordCount / PageSize);
int pageCount = (int)Math.Ceiling(dblPageCount);
if (pageCount > 1)
{
findex = currentPage - 5;
//Set Last index value if current page less than 5 then last index added "5" values to the Current page else it set "10" for last page number
if (currentPage > 5)
{
//lindex = currentPage + 4;
//findex = lindex - 5;
lindex = currentPage + 4;
findex = currentPage;
}
else
{
lindex = 5;
}
//Check last page is greater than total page then reduced it to total no. of page is last index
if (lindex > pageCount)
{
lindex = pageCount;
//findex = currentPageIndex;
findex = lindex - 1;
}
if (findex <= 0)
{
findex = 1;
}
List<ListItem> pages = new List<ListItem>();
if (pageCount > 1)
{
pages.Add(new ListItem("First", "1", currentPage > 1));
if (findex > 1)
{
int index = findex - 1;
pages.Add(new ListItem("..", index.ToString(), true));
}
else
{
pages.Add(new ListItem("..", findex.ToString(), false));
}
for (int i = findex; i <= lindex; i++)
{
pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
}
if (lindex >= 5 & lindex < pageCount)
{
lindex = lindex + 1;
pages.Add(new ListItem("..", lindex.ToString(), true));
}
else
{
pages.Add(new ListItem("..", lindex.ToString(), false));
}
pages.Add(new ListItem("Last", pageCount.ToString(), currentPage < pageCount));
}
rptPager.DataSource = pages;
rptPager.DataBind();
}
}
pls使用上一个和下一个逻辑在上面的代码中进行相应的更改..
pls change accordingly in above code with previous and next logic..
推荐答案
您好,
查看此链接
使用C#在ASP.Net中对Gridview,DataGrid,DataList和Repeater Control进行自定义分页 [ ^ ]
这篇关于转发器控件中的自定义分页,而不是在c#.net中使用pagedatasource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!