I'm developing a dynamic data web app. On list.aspx page it has GridViewPager control for paging, it option in drop down list as 10,20,.. rows in a page like that, but it does not an option show all rows in a page. How I can add "Al开发者_开发问答l" option in it?
I assume you are referring to a GridView and the automatic paging functionality included. If not please clarify. However, if this is the case then the default paging options do not include a show all. You can roll your own, I would start here: http://msdn.microsoft.com/en-us/library/5aw1xfh3.asp
In content folder Dynamic Data site lies the code for GridViewPager control.
What I have done is I added "All" option in dropdown list with values 0, and in the code behind file in function DropDownListPageSize_SelectedIndexChanged I check if selected value is 0 then set AllowPaging = false else true.
protected void DropDownListPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
if (_gridView == null)
{
return;
}
DropDownList dropdownlistpagersize = (DropDownList)sender;
int sz=Convert.ToInt32(dropdownlistpagersize.SelectedValue);
//_gridView.PageSize = Convert.ToInt32(dropdownlistpagersize.SelectedValue);
if (sz<=0)
{
_gridView.AllowPaging = false;
//_gridView.DataBind();
//return;
}
else
{
_gridView.AllowPaging = true;
_gridView.PageSize = sz;
_gridView.AllowPaging = true;
}
int pageindex = _gridView.PageIndex;
_gridView.DataBind();
if (_gridView.PageIndex != pageindex)
{
//if page index changed it means the previous page was not valid and was adjusted. Rebind to fill control with adjusted page
_gridView.DataBind();
}
}
You will have to implement your own pager and attached it to the Gridview. Default pager will not give you this option. May be this link could help you. http://www.codeproject.com/KB/grid/GridView_pager.aspx
精彩评论