Hi ,
Iam using Dnngrid in my module which i have created dynamically .
I used paging for the grid but when i try to navigate other page in grid , my page is getting refreshed.
Please let me know if you have any idea.
Below is the code iam using.
namespace Philip.Modules.IspaceTimesheetDnn
{
public partial class Summary : PortalModuleBase
{
DotNetNuke.Web.UI.WebControls.DnnGrid dgDNNGrid = new DotNetNuke.Web.UI.WebControls.DnnGrid();
//override protected void OnInit(EventArgs e)
//{
// InitializeComponent();
// base.OnInit(e);
//}
//private void InitializeComponent()
//{
// this.Load += new System.EventHandler(this.Page_Load);
// dgDNNGrid.PageIndexChanged += new GridPageChangedEventHandler(dgDNNGrid_PageIndexChanged);
//}
protected void Page_Init(System.Object sender, System.EventArgs e)
{
dgDNNGrid.PageIndexChanged += new GridPageChangedEventHandler(dgDNNGrid_PageIndexChanged);
}
protected void Page_Load(System.Object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
//dgDNNGrid.PageIndexChanged += new GridPageChangedEventHandler(dgDNNGrid_PageIndexChanged);
}
protected void btnGet_Click(object sender, EventArgs e)
{
BindData();
// dgDNNGrid.NeedDataSource += new GridNeedDataSourceEventHandler(dgDNNGrid_NeedDataSource);
}
protected void dgDNNGrid_PageIndexChanged(object source, GridPageChangedEventArgs e)
{
dgDNNGrid.DataSource = (DataTable)Session["DataSource"];
dgDNNGrid.CurrentPageIndex = e.NewPageIndex;
dgDNNGrid.DataBind();
}
protected void BindData()
{
DataTable dtgrid = Getdata();
//DotNetNuke.Web.UI.WebControls.DnnGrid dgDNNGrid = new DotNetNuke.Web.UI.WebControls.DnnGrid();
dgDNNGrid.AutoGenerateColumns = true;
dgDNNGrid.CellSpacing = 0;
dgDNNGrid.GridLines = GridLines.Both;
dgDNNGrid.FooterStyle.CssClass = "DataGrid_Footer";
dgDNNGrid.HeaderStyle.CssClass = "DataGrid_Header";
dgDNNGrid.ItemStyle.CssClass = "DataGrid_Item";
dgDNNGrid.AlternatingItemStyle.CssClass = "DataGrid_AlternatingItem";
dgDNNGrid.Width = Unit.Pixel(1000);
dgDNNGrid.Height = Unit.Pixel(400);
dgDNNGrid.DataSource = dtgrid;
dgDNNGrid.DataBind();
dgDNNGrid.ClientSettings.Scrolling.UseStaticHeaders = true;
dgDNNGrid.ClientSettings.Scrolling.AllowScroll = true;
dgDNNGrid.ClientSettings.Scrolling.FrozenColumnsCount = 2;
dgDNNGrid.ClientSettings.Scrolling.EnableVirtualScrollPaging = true;
dgDNNGrid.AllowSorting = true;
dgDNNGrid.AllowPaging = true;
dgDNNGrid.PageSize = 25;
dgDNNGrid.PagerStyle.AlwaysVisible = true;
dgDNNGrid.PagerStyle.Mode = GridPagerMode.NumericPages;
if (dtgrid.Rows.Count > 0)
{
dgDNNGrid.VirtualItemCount = dtgrid.Rows.Count - 1;
dgDNNGrid.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
}
dgDNNGrid.EnableViewState = true;
for (int i = 0; i < dgDNNGrid.MasterTableView.AutoGeneratedColumns.Length; i++)
{
(dgDNNGrid.MasterTableView.AutoGeneratedColumns[i] as GridBoundColumn).DataFormatString = "<nobr>{0}</nobr>";
}
dgDNNGrid.Rebind();
Panel2.Controls.Add(dgDNNGrid);
//grdSummary.DataSource = dtgrid;
this.Session["DataSource"] = dgDNNGrid.DataSource;
// grdSummary.DataBind();
}
Thank in advance
Divya.