Telerik RadGrid Paging - Duplicate Records and Overlay Buttons

I recently started using ASP.Net and Telerik RadGrid, but ran into a problem:

My RadGrid object is in the UserControl object in the Custom Control object inside the page object (which the script manager has).

I have several UserControls inside the specified user control, each of which contains markup for the RadGrid object, as shown below:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AreaListRadGrid.ascx.cs" Inherits="WebControls.AreaListRadGrid" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %> <telerik:RadAjaxPanel runat="server" ID="radAjaxPanel" EnableAJAX="true" LoadingPanelID="radAjaxLoadingPanel"> <telerik:RadGrid AllowPaging="true" AutoGenerateColumns="false" DataSourceID="gridData" EnableViewState="true" GridLines="None" ID="radGrid" runat="server"> <PagerStyle Mode="NumericPages" /> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="ColA" HeaderText="A" /> <telerik:GridBoundColumn DataField="ColB" HeaderText="B" /> <telerik:GridBoundColumn DataField="ColC" HeaderText="C" /> <telerik:GridBoundColumn DataField="ColD" HeaderText="D" /> <telerik:GridBoundColumn DataField="ColE" HeaderText="E" /> </Columns> </MasterTableView> </telerik:RadGrid> </telerik:RadAjaxPanel> <asp:ObjectDataSource ID="gridData" runat="server" SelectMethod="GetData" SelectCountMethod="GetDataCount" OnObjectCreating="dataObjectCreating" TypeName="AreaListRadGrid"> </asp:ObjectDataSource> <telerik:RadAjaxLoadingPanel runat="server" ID="radAjaxLoadingPanel"> Loading please wait.... </telerik:RadAjaxLoadingPanel> 

I changed the names of the columns and namespaces to something not related to the project, but the grid is loading.

As with a user control, it is created as follows:

 var view = (AreaListRadGrid)this.TemplateControl.LoadControl(".\\WebControls\\AreaListRadGrid.ascx"); view.DataSource = dataSet; areaCenterMiddle.Controls.Add(view); view.RadGrid.Rebind(); 

the dataSet variable is of type System.Data.DataSet .

So, when I launch this site, the Rad Grid grid appears. I have a grid with 4 rows, 3 of which are on page 1, and the last row is on page 2. initial radgridafter page 2 click When I click on page 2, everything happens as expected. The style of the page buttons changes, and the lines from page 1 are deleted, and the line from page 2 is added to the grid. Big! What happens next, I do not understand:

When you press page 1 again, the stylization of the page 2 button does not change (so that it is still as if pressed), and lines 2 and 3 are displayed in the grid, but the first line is the line that was included on page 2.

re-visit to page 1

it seems that page 2 is not cleared when page 1 loads, I am not sure why and how this happens. Anyone have any ideas what I'm doing wrong?

Thank your help.

Greetings

Rob

+8
telerik radgrid
source share
2 answers

I am sure you already understood this, but I wonder if this is a side effect without setting the NeedDataSource property using the grid data source?

add this to the front end RadGrid control.

OnNeedDataSource = "radGrid_NeedDataSource"

and process it in code.

protected void radGrid_NeedDataSource (object sender, GridNeedDataSourceEventArgs e) {view.RadGrid.DataSource = gridData; }

+1
source share

You do not need to provide a dataset to the grid at boot time. The dataset is retrieved using the DataSourceID that you set in the design when necessary.

Delete "view.DataSource = dataSet;" and the replay function, and everything should work properly.

0
source share

All Articles