Link to home
Start Free TrialLog in
Avatar of ToolTimeGang
ToolTimeGangFlag for United States of America

asked on

gridview pagesize value set by web.config not working

I would like to set the gridview pagesize value from a web.config entry.
Web.config has this:
<appSettings>
    <add key="pagingSize" value="20" />
</appSettings>

Open in new window


gridview has this:
                <asp:GridView ID="gvCustomers1" runat="server" DataSourceID="odsCustomers" 
                    AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" 
                    EmptyDataText="No data exists" CssClass="siteTable"  
                    DataKeyNames="CustomerID" ViewStateMode="Enabled" 
                    PageSize="<%$  appSettings:pagingSize %>" >

Open in new window

But this is not working.  I get "Int32Converter cannot convert from (null)".  If I hardcode it to 20, it works just fine.

Can you please tell me what I am doing wrong?  Thank you!
ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ToolTimeGang

ASKER

Wow!  that was quick.  And it makes sense to me!  so then my setting would be like this:
PageSize=<%= GetPageSize %>

right?  (of course I would first have to add the logic in my code behind)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a bunch!  I'm good now!!!  I sure will mark your answer as helpful!
Very speedy with answers.  2nd time today!  That is appreciated so very much!
You are most welcome,
Thanks