I am using RadGrid in Sample Webpart. With Paging enabled I am getting following problem Sequence of Step Performed :
1. When Click on Page no in Sequence [i.e 1,2,3,4...] Data Displayed is proper But Suppose
2. When i Clicked on Page 1 after page 3 i am getting Data Displayed of Page 3 on Page .
Note : this problem occur When i click on Page 1 after any other page.if i click Page 2 after any other page it work.
Can you please let me know what would be the problem
Sample code Webpart:
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Telerik.WebControls;
using System.Data;
namespace Wachovia.CIBT.Portal.Internet.WebParts
{
/// <summary>
/// Description for SampleGrid.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:SampleGrid runat=server></{0}:SampleGrid>"),
XmlRoot(Namespace="Wachovia.CIBT.Portal.Internet.WebParts")]
public class SampleGrid : Microsoft.SharePoint.WebPartPages.WebPart
{
private const string defaultText = "";
private string text = defaultText;
RadGrid oGrid = new RadGrid();
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(defaultText),
WebPartStorage(Storage.Personal),
FriendlyName("Text"),
Description("Text Property")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// This method gets the custom tool parts for this Web Part by overriding the
/// GetToolParts method of the WebPart base class. You must implement
/// custom tool parts in a separate class that derives from
/// Microsoft.SharePoint.WebPartPages.ToolPart.
/// </summary>
///<returns>An array of references to ToolPart objects.</returns>
// public override ToolPart[] GetToolParts()
// {
// ToolPart[] toolparts = new ToolPart[2];
// WebPartToolPart wptp = new WebPartToolPart();
// CustomPropertyToolPart custom = new CustomPropertyToolPart();
// toolparts[0] = wptp;
// toolparts[1] = custom;
// return toolparts;
// }
/// <summary>
/// Render this Web Part to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void RenderWebPart(HtmlTextWriter output)
{
this.oGrid.RenderControl(output);
}
protected override void CreateChildControls()
{
oGrid = new RadGrid();
oGrid.ID="oGrid";
oGrid.Attributes.Add("runat","server");
oGrid.AutoGenerateColumns=true;
oGrid.AllowPaging=true;
oGrid.PageSize=10;
oGrid.PagerStyle.Mode= GridPagerMode.NextPrevAndNumeric;
oGrid.PagerStyle.Position = GridPagerPosition.TopAndBottom;
oGrid.AllowMultiRowSelection=true;
oGrid.AllowMultiRowEdit=false;
oGrid.DataSource=GetDatavalues();
oGrid.DataBind();
this.Controls.Add(oGrid);
}
public DataTable GetDatavalues()
{
DataTable dt_ContentCategoryDetails = new DataTable("BusinessLine");
dt_ContentCategoryDetails.Columns.Add("ID",System.Type.GetType("System.String"));
dt_ContentCategoryDetails.Columns.Add("Description",System.Type.GetType("System.String"));
dt_ContentCategoryDetails.Columns.Add("ParentID",System.Type.GetType("System.String"));
DataRow dr_Details;
for(int i=0;i<=100;i++)
{
dr_Details = dt_ContentCategoryDetails.NewRow();
dr_Details["ID"]= i;
dr_Details["Description"] = "hello World" + i;
dt_ContentCategoryDetails.Rows.Add(dr_Details);
}
return dt_ContentCategoryDetails;
}
}
}