views:

1075

answers:

2

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?

+1  A: 

It's in the gridview control (~\DynamicData\PageTemplates\List.aspx)

<asp:Gridview PageSize="20" runat="server" ID="GridView">

I can't recall if it comes with any PageSize attribute by default but you can add it in if it doesn't.

It doesn't come with a PageSize attribute by default, but I added it and it resolved the issue completely. Thank you for your help!
Registered User
+1  A: 

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>
Wizzard
This works too and better suits my needs.
Registered User

related questions