473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DataGrid - used to work.. not any more

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.DataGridPageChangedEvent Handler(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.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
PoplulateProductRelatedInfo((int)ViewState["ProductID"]);
}
}
}
--
Regards,

HD
Nov 18 '05 #1
1 1052
Found out what it was....
The last thing well ... the last to last thing i changed was disabling the
viewstate of the datagrid.
just thought... y not enable it and see what happens...

guess what... it starts working.... lol

--
Regards,

HD

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
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.DataGridPageChangedEvent Handler(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.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
PoplulateProductRelatedInfo((int)ViewState["ProductID"]);
}
}
}
--
Regards,

HD

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Douglas Buchanan | last post by:
Some say there is no new row event for the VB.Net DataGrid. Hard to believe! Is that really true? I want to create a GUID in a hidden ID column when the user begins to enter data into a new row....
0
by: Frosty | last post by:
Hi I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
2
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
1
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so...
6
by: Beren | last post by:
Hi all I'm almost braindead on this one, but how can I create a master/detail datagrid in this format : CatA subcatA1 subcatA2 subcatA3
9
by: John Hernry | last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and scouring the net looking for a solution to my datagrid find functionality. With no luck. I am hoping that you can help me....
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.