Senthil ramna
Top achievements
Rank 1
Senthil ramna
asked on 25 Apr 2010, 10:57 AM
I am facing a little problem when using paging in my Radgrid.
Pager style mode i have chosen NextPrevAnd Numeric, so in this mode with the previous and next and numeric there is a another field that appears when running my page which is PageSize and has a dropdown that takes by default the pagesize that we have declared.
So the problem that i am facing is when i select in that Pagesize dropdown let's say pagesize as 10 or 20 or 50 the Grid is disappearing.
So do i need to bind it in some event or what.
Please need some suggestions.
Pager style mode i have chosen NextPrevAnd Numeric, so in this mode with the previous and next and numeric there is a another field that appears when running my page which is PageSize and has a dropdown that takes by default the pagesize that we have declared.
So the problem that i am facing is when i select in that Pagesize dropdown let's say pagesize as 10 or 20 or 50 the Grid is disappearing.
So do i need to bind it in some event or what.
Please need some suggestions.
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 26 Apr 2010, 07:08 AM
Hi,
I guess you are using simple data-binding, that is calling the DataBind() method on the first page load when !Page.IsPostBack. If you select simple data-binding, you need to assign data-source and rebind the grid after each operation (paging, sorting, editing, etc.). So set the datasource of grid in OnPageSizeChanged event as shown in the demo.
cs:
aspx:
A better approach would be using Advanced DataBinding of a RadGrid control using NeedDataSource event, which does not require to bound to a data source in each grid events explicitly. Checkout the demo for more information about Advanced DataBinding.
Advanced Data Binding
Regards
Princy.
I guess you are using simple data-binding, that is calling the DataBind() method on the first page load when !Page.IsPostBack. If you select simple data-binding, you need to assign data-source and rebind the grid after each operation (paging, sorting, editing, etc.). So set the datasource of grid in OnPageSizeChanged event as shown in the demo.
cs:
protected void RadGrid1_PageSizeChanged(object source, Telerik.Web.UI.GridPageSizeChangedEventArgs e) |
{ |
//Method for binding the grid |
LoadData(); |
} |
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" GridLines="None" AllowPaging="true" |
PageSize="5" OnPageIndexChanged="RadGrid1_PageIndexChanged" OnPageSizeChanged="RadGrid1_PageSizeChanged1"> |
<MasterTableView> |
......... |
......... |
</MasterTableView> |
</telerik:RadGrid> |
A better approach would be using Advanced DataBinding of a RadGrid control using NeedDataSource event, which does not require to bound to a data source in each grid events explicitly. Checkout the demo for more information about Advanced DataBinding.
Advanced Data Binding
Regards
Princy.
0
Senthil ramna
Top achievements
Rank 1
answered on 26 Apr 2010, 01:56 PM
Thanks for the reply princy but still facing the same problem.
Let me show how my page looks :
<telerik:RadGrid ID="RadGrid1" Width="100%" GridLines="Vertical" AllowPaging="true" |
runat="server" Skin="Web20" PageSize="10"onpageindexchanged="RadGrid1_PageIndexChanged" |
onpagesizechanged="RadGrid1_PageSizeChanged" >
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" /> |
protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e) |
{ |
RadGrid1.CurrentPageIndex = e.NewPageIndex; |
gridBind(); |
} |
protected void RadGrid1_PageSizeChanged(object source, GridPageSizeChangedEventArgs e) |
{ |
gridBind(); |
} |
Now in the pager control the Next works fine the Previous button works fine, navigate to Last page works fine also navigate to First page works fine.
but the drop down that is there after this saying PageSize showing 10 by default (as thatis what i have declared) when i select 50 or 100 then grid dispappears.
Also the OnPageSizeChanged Event doesnot fire at all it ony fires if i use pager style as Advanced, whereas OnPageIndexChanged is working fine.
And the data is there i.e there are 200 items to be displayed.
Please do tell me if i am making any mistakes anywhere.
again thanks for the reply
0
Hi Senthil,
In order to achieve your goal I suggest that you switch to advanced binding with NeedDataSource event handling and see whether this helps.
Additionally, the following help article shows the steps on how to implement simple data-binding with paging. You need to bind the grid on page load and in the PageIndexChanged event handler as shown below:
http://www.telerik.com/help/aspnet-ajax/grdsimpledatabinding.html
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
In order to achieve your goal I suggest that you switch to advanced binding with NeedDataSource event handling and see whether this helps.
Additionally, the following help article shows the steps on how to implement simple data-binding with paging. You need to bind the grid on page load and in the PageIndexChanged event handler as shown below:
http://www.telerik.com/help/aspnet-ajax/grdsimpledatabinding.html
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Senthil ramna
Top achievements
Rank 1
answered on 28 Apr 2010, 02:13 PM
Thanks for the reply Pavlina and i have done like wat you suggested.
Everything works fine except there is one problem.
In Advanced Databinding it is suggested that i should not call the DataBind() method.
It says in error message that Databind would take place automatically right after NeedDataSource handler finishes excution.
The thing is when i do this the pager mode which i said had problems is working fine dropdown is working fine the next, prev, first, last and even the dropdown for pagesize is working fine except that i get this above error message every time i bind() the grid please do suggest a solution.
another thing i tried using Advanced databinding in a test page and using it works fine, but here this error message comes.
please tell me how i can use Advanced Databinding if i am using a method to bind my grid as i am using this method in a lot of places in this page so please do excuse for being so naieve, i am new to .Net.
Everything works fine except there is one problem.
In Advanced Databinding it is suggested that i should not call the DataBind() method.
It says in error message that Databind would take place automatically right after NeedDataSource handler finishes excution.
The thing is when i do this the pager mode which i said had problems is working fine dropdown is working fine the next, prev, first, last and even the dropdown for pagesize is working fine except that i get this above error message every time i bind() the grid please do suggest a solution.
another thing i tried using Advanced databinding in a test page and using it works fine, but here this error message comes.
please tell me how i can use Advanced Databinding if i am using a method to bind my grid as i am using this method in a lot of places in this page so please do excuse for being so naieve, i am new to .Net.
0
Accepted
Hi Senthil,
To avoid this problem you should move your databinding logic to the NeedDataSource event and call the grid's Rebind() method when you need to rebind the grid outside of that event.
Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
To avoid this problem you should move your databinding logic to the NeedDataSource event and call the grid's Rebind() method when you need to rebind the grid outside of that event.
Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Senthil ramna
Top achievements
Rank 1
answered on 30 Apr 2010, 04:30 AM
Thanks for your help Pavlina got it to work.
I went through the entire link on Advanced and Simple Databinding helped me understand it better.
Thanks again for the quick responses.
I went through the entire link on Advanced and Simple Databinding helped me understand it better.
Thanks again for the quick responses.