cb:AbleGridView page size changing event

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

cb:AbleGridView page size changing event

Post by jmestep » Fri May 23, 2014 4:08 am

I am using this gridview with a datasource from a database query in the code behind and am trying to get the page size on the grid to change. I change it, then it changes right back. I was having trouble with the paging itself but figured that out by using the following

Code: Select all

protected void ShipmentsGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.ShipmentsGrid.PageIndex = e.NewPageIndex;
            BindShipmentsGrid();        

        }
How can I pick up the page size changed event? I tried Request.Form and was able to get the new size, but was having trouble inserting it at the right sequence in the page events. I'm sure there is a better way, but I just haven't found it yet. It seems that all the times you use the control is from an object datasource.
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: cb:AbleGridView page size changing event

Post by mazhar » Thu Jun 26, 2014 3:50 am

Did you provided the PageSize value on gridview itself in markup? If yes what was it?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: cb:AbleGridView page size changing event

Post by jmestep » Thu Jun 26, 2014 4:43 am

I really had to dig on this one to remember what I was working on more than a month ago!
Here is the code- I had to set it at 50 since it wouldn't page.

Code: Select all

<cb:AbleGridView  ID="ShipmentsGrid" SkinID="PagedList" runat="server" AllowPaging="True"  AutoGenerateColumns="False"  OnPageIndexChanging="ShipmentsGrid_PageIndexChanging" PageSize="50" OnRowDataBound="ShipmentsGrid_RowDataBound" ShowHeader="true" GridLines="None" PagerSettings-Position="TopAndBottom" >
Here are things I tried in the code behind, as far as I remember

Code: Select all

in page load
               ShipmentsGrid.PageSizeOptions= "50:50";
                ShipmentsGrid.PagerMode = CommerceBuilder.UI.WebControls.AbleGridView.PagerType.Custom;
                //if (Page.IsPostBack)
                //{
                //    ShipmentsGrid.PageSizeOptions = string.Format("{0}:{0}|{1}:{1}", 20, 40);
                //}
                 BindShipmentsGrid();

Code: Select all

 protected void Page_Init(object sender, EventArgs e)
        {
            //doesn't work
            if (Page.IsPostBack)
            {
                //int pageSize = AlwaysConvert.ToInt(Request.Form["ctl00$MainContent$ShipmentsGrid$ctl01$ctl11"]);
                //ShipmentsGrid.PageSize = pageSize;
                //ShipmentsGrid.PageSizeOptions = string.Format("{0}:{0}|{1}:{1}",20,40);
            }
        }
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: cb:AbleGridView page size changing event

Post by mazhar » Thu Jun 26, 2014 11:35 pm

Here are the defaults for PageSizeOptions

Code: Select all

PageSizeOptions = "Show All:0|5:5|10:10|20:20|50:50|100:100"
Instead of setting them via code better try to set it in HTML markup. Like you set other properties on GridView. I was thinking maybe page size you provided was not in available size options.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: cb:AbleGridView page size changing event

Post by jmestep » Fri Jun 27, 2014 4:05 am

I knew those were the defaults from looking at the source code. I have removed all the page size settings from the code behind and put this in the markup and it still happens. I'll dig around further.

Code: Select all

<cb:AbleGridView  ID="ShipmentsGrid" SkinID="PagedList" runat="server" AllowPaging="True"  AutoGenerateColumns="False"  OnPageIndexChanging="ShipmentsGrid_PageIndexChanging" PageSize="20" OnRowDataBound="ShipmentsGrid_RowDataBound" ShowHeader="true" GridLines="None" PagerSettings-Position="TopAndBottom" PageSizeOptions = "Show All:0|5:5|10:10|20:20|50:50|100:100" >
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: cb:AbleGridView page size changing event

Post by jmestep » Wed Jul 15, 2015 8:18 am

Well, here I am a year later and am still having the same problem on a different page. The paging works until I select another page size in the dropdown. Is there a method on the grid view that I should trigger when I change the page size? It seems like all of your code using the grid is bound via an object datasource. I am binding from the code behind.
Here is my code and thanks for any help.

Code: Select all

 <cb:AbleGridView ID="KeycodeGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="KeycodeId" AllowPaging="true" PageSize="5"     <cb:AbleGridView ID="KeycodeGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="KeycodeId" AllowPaging="true"  PagerSettings-Position="TopAndBottom"   OnPageIndexChanging="KeycodeGrid_PageIndexChanging"
                    TotalMatchedFormatString="<span id='searchCount'>{0}</span> matching keycodes" 
                    AllowSorting="true" SkinID="PagedList" Width="100%" OnRowCommand="KeycodeGrid_RowCommand" Visible="false"  PageSizeOptions = "Show All:0|5:5|10:10|20:20|50:50|100:100" OnSelectedIndexChanging="KeycodeGrid_SelectedIndexChanging">
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: cb:AbleGridView page size changing event

Post by AbleMods » Fri Jul 17, 2015 3:24 am

I've had similar issues because I didn't notice that viewstate was disabled on the page or on the control in question. Sometimes it's the parent placeholder or parent panel that has viewstate disabled. So even though the page size was getting set in the postback, it wasn't sticking.

To check it, I would set the value and put a breakpoint at the beginning of page_load so I could check the control's PageSize property. Then try to walk forward through the code to see if I can find where it's changing back to a previous value.

Hope that helps. Won't fix it, but could give you a little more insight.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: cb:AbleGridView page size changing event

Post by mazhar » Fri Jul 17, 2015 12:55 pm

I just tried a small test. On Admin/Marketting/Coupons/Default.aspx I updated the AbleGridView defention like below

Code: Select all

<cb:AbleGridView ID="CouponGrid" runat="server" 
                    AutoGenerateColumns="False" 
                    DataKeyNames="Id"
                    DataSourceID="CouponDs" 
                    AllowPaging="True" 
                    PageSize="1" 
                    TotalMatchedFormatString="<span id='searchCount'>{0}</span> matching coupons" 
                    SkinID="PagedList" 
                    ShowWhenEmpty="False" 
                    AllowMultipleSelections="False"
                    AllowSorting="true" 
                    Width="100%" 
                    DefaultSortExpression="Name" 
                    OnRowDataBound="CouponGrid_RowDataBound"
                    OnRowCommand="CouponGrid_RowCommand" PageSizeOptions="Show All:0|1:1|15:15|20:20|70:70">
Notice the PageSize and PageSizeOptions. It does seems to be working for me.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: cb:AbleGridView page size changing event

Post by jmestep » Mon Jul 20, 2015 1:12 am

I did finally get this working on a gridview that was bound from the code behind. I had to explicitly disable viewstate on it.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: cb:AbleGridView page size changing event

Post by mazhar » Tue Jul 21, 2015 5:54 am

Good to know that you have it working.

Post Reply