Search code examples
dynamic-dataasp.net-3.5

Dynamic Data Web Application: How do I change the default filter so that it displays more than 10 rows?


Dynamic Data Web Application

How do I change the default filter so that it displays more than 10 rows?

I recently created a Dynamic Data website to help manage a few dozen lookup tables for my business intelligence data warehouse and I am having trouble manipulating the template. I would like to make the default number of rows displayed in the details pages more than 10 rows. Although I found the portion of the data grid that allows me to change the filter drop down list, I still can't seem to find the code that forces the data grid to only show 10 rows. How do I change the default number of rows displayed by the data grid in the standard template of a Dynamic Data website?


Solution

  • If you open the ~/DynamicData/Content folder you will find the pager see GridViewPager.ascx You can edit this as this is the pager used on all gridviews, in the codebehind you will see this field at the top

    You can change the number of rows per page in the page or you can set the default in the code behind.

    protected void Page_Load(object sender, EventArgs e)
    {
        Control c = Parent;
        while (c != null)
        {
            if (c is GridView)
            {
                _gridView = (GridView)c;
                break;
            }
            c = c.Parent;
        }
        ***_gridView.PageSize = 20;***
    }
    

    Add the line in BOLD ITALIC to set the initial page size and to change the page size value int he list box edit the page its self:

    <asp:DropDownList ID="DropDownListPageSize" runat="server" 
        AutoPostBack="true" 
        CssClass="droplist" 
        onselectedindexchanged="DropDownListPageSize_SelectedIndexChanged">
        <asp:ListItem Value="5" />
        <asp:ListItem Value="10" />
        <asp:ListItem Value="15" />
        <asp:ListItem Value="20" />
    </asp:DropDownList>