H
Hermit Dave
Hello folks,
Attaching some code from one of my pages... the paging on this page used to
work just fine.... when i click next it doesnt even come anywhere near the
DataGrid1_PageIndexChanged handler... tried step by step debug... just exits
after the page_load when i try to move to the next page...
Any ideas would be appreciated....
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using WebShop.Components;
namespace WebShop.ShopAdmin
{
/// <summary>
/// Summary description for CA_ShowProductColors.
/// </summary>
public class CA_ShowProductColors : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblFoundIn;
protected System.Web.UI.WebControls.Label lblProductIdentifier;
protected System.Web.UI.WebControls.Label lblUnitCost;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Label lblProductName;
protected System.Web.UI.WebControls.LinkButton lnkBack;
protected WebShop.ShopAdmin.Label ModuleTitle1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
if(Request["ProductID"]!=null & Request["ProductID"]!="")
{
int ProductID = int.Parse(Request["ProductID"]);
PoplulateProductRelatedInfo(ProductID);
ViewState["URLReferrer"] = Request.UrlReferrer;
ViewState["ProductID"] = ProductID;
}
}
}
private void PoplulateProductRelatedInfo(int ProductID)
{
ProductsDB myProductsDB = new ProductsDB();
ProductDetail myProduct = myProductsDB.GetProduct(ProductID);
lblFoundIn.Text = myProduct.productFoundIn;
lblProductIdentifier.Text = myProduct.productIdentifier;
lblProductName.Text = myProduct.productName;
lblUnitCost.Text = myProduct.unitCost;
bool getOnlyActiveProductColors = false;
DataSet ProductColors = myProductsDB.GetProductColors(ProductID,
getOnlyActiveProductColors);
DataGrid1.DataSource = ProductColors;
DataGrid1.DataBind();
//Find the ModuleTitle and set its EditUR:
ModuleTitle1.EditUrl = "CA_EditProductColor.aspx?ProductID=" + ProductID
+ "&ProductName=" + myProduct.productName;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_Pag
eIndexChanged);
this.lnkBack.Click += new System.EventHandler(this.lnkBack_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void lnkBack_Click(object sender, System.EventArgs e)
{
Response.Redirect(ViewState["URLReferrer"].ToString());
}
private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
PoplulateProductRelatedInfo((int)ViewState["ProductID"]);
}
}
}
Attaching some code from one of my pages... the paging on this page used to
work just fine.... when i click next it doesnt even come anywhere near the
DataGrid1_PageIndexChanged handler... tried step by step debug... just exits
after the page_load when i try to move to the next page...
Any ideas would be appreciated....
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using WebShop.Components;
namespace WebShop.ShopAdmin
{
/// <summary>
/// Summary description for CA_ShowProductColors.
/// </summary>
public class CA_ShowProductColors : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblFoundIn;
protected System.Web.UI.WebControls.Label lblProductIdentifier;
protected System.Web.UI.WebControls.Label lblUnitCost;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Label lblProductName;
protected System.Web.UI.WebControls.LinkButton lnkBack;
protected WebShop.ShopAdmin.Label ModuleTitle1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
if(Request["ProductID"]!=null & Request["ProductID"]!="")
{
int ProductID = int.Parse(Request["ProductID"]);
PoplulateProductRelatedInfo(ProductID);
ViewState["URLReferrer"] = Request.UrlReferrer;
ViewState["ProductID"] = ProductID;
}
}
}
private void PoplulateProductRelatedInfo(int ProductID)
{
ProductsDB myProductsDB = new ProductsDB();
ProductDetail myProduct = myProductsDB.GetProduct(ProductID);
lblFoundIn.Text = myProduct.productFoundIn;
lblProductIdentifier.Text = myProduct.productIdentifier;
lblProductName.Text = myProduct.productName;
lblUnitCost.Text = myProduct.unitCost;
bool getOnlyActiveProductColors = false;
DataSet ProductColors = myProductsDB.GetProductColors(ProductID,
getOnlyActiveProductColors);
DataGrid1.DataSource = ProductColors;
DataGrid1.DataBind();
//Find the ModuleTitle and set its EditUR:
ModuleTitle1.EditUrl = "CA_EditProductColor.aspx?ProductID=" + ProductID
+ "&ProductName=" + myProduct.productName;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_Pag
eIndexChanged);
this.lnkBack.Click += new System.EventHandler(this.lnkBack_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void lnkBack_Click(object sender, System.EventArgs e)
{
Response.Redirect(ViewState["URLReferrer"].ToString());
}
private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
PoplulateProductRelatedInfo((int)ViewState["ProductID"]);
}
}
}