473,769 Members | 4,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_PageI ndexChanged 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.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using WebShop.Compone nts;

namespace WebShop.ShopAdm in
{
/// <summary>
/// Summary description for CA_ShowProductC olors.
/// </summary>
public class CA_ShowProductC olors : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l lblFoundIn;
protected System.Web.UI.W ebControls.Labe l lblProductIdent ifier;
protected System.Web.UI.W ebControls.Labe l lblUnitCost;
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
protected System.Web.UI.W ebControls.Imag e Image1;
protected System.Web.UI.W ebControls.Labe l lblProductName;
protected System.Web.UI.W ebControls.Link Button lnkBack;
protected WebShop.ShopAdm in.Label ModuleTitle1;

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
if(Request["ProductID"]!=null & Request["ProductID"]!="")
{
int ProductID = int.Parse(Reque st["ProductID"]);
PoplulateProduc tRelatedInfo(Pr oductID);
ViewState["URLReferre r"] = Request.UrlRefe rrer;
ViewState["ProductID"] = ProductID;
}
}
}

private void PoplulateProduc tRelatedInfo(in t ProductID)
{
ProductsDB myProductsDB = new ProductsDB();
ProductDetail myProduct = myProductsDB.Ge tProduct(Produc tID);
lblFoundIn.Text = myProduct.produ ctFoundIn;
lblProductIdent ifier.Text = myProduct.produ ctIdentifier;
lblProductName. Text = myProduct.produ ctName;
lblUnitCost.Tex t = myProduct.unitC ost;

bool getOnlyActivePr oductColors = false;
DataSet ProductColors = myProductsDB.Ge tProductColors( ProductID,
getOnlyActivePr oductColors);
DataGrid1.DataS ource = ProductColors;
DataGrid1.DataB ind();

//Find the ModuleTitle and set its EditUR:
ModuleTitle1.Ed itUrl = "CA_EditProduct Color.aspx?Prod uctID=" + ProductID
+ "&ProductNa me=" + myProduct.produ ctName;

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.DataGrid1. PageIndexChange d += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.DataGrid1_Pa g
eIndexChanged);
this.lnkBack.Cl ick += new System.EventHan dler(this.lnkBa ck_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void lnkBack_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct(ViewState["URLReferre r"].ToString());
}

private void DataGrid1_PageI ndexChanged(obj ect source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
DataGrid1.Curre ntPageIndex = e.NewPageIndex;
PoplulateProduc tRelatedInfo((i nt)ViewState["ProductID"]);
}
}
}
--
Regards,

HD
Nov 18 '05 #1
1 1069
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******** ******@TK2MSFTN GP11.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_PageI ndexChanged 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.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using WebShop.Compone nts;

namespace WebShop.ShopAdm in
{
/// <summary>
/// Summary description for CA_ShowProductC olors.
/// </summary>
public class CA_ShowProductC olors : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l lblFoundIn;
protected System.Web.UI.W ebControls.Labe l lblProductIdent ifier;
protected System.Web.UI.W ebControls.Labe l lblUnitCost;
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
protected System.Web.UI.W ebControls.Imag e Image1;
protected System.Web.UI.W ebControls.Labe l lblProductName;
protected System.Web.UI.W ebControls.Link Button lnkBack;
protected WebShop.ShopAdm in.Label ModuleTitle1;

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
if(Request["ProductID"]!=null & Request["ProductID"]!="")
{
int ProductID = int.Parse(Reque st["ProductID"]);
PoplulateProduc tRelatedInfo(Pr oductID);
ViewState["URLReferre r"] = Request.UrlRefe rrer;
ViewState["ProductID"] = ProductID;
}
}
}

private void PoplulateProduc tRelatedInfo(in t ProductID)
{
ProductsDB myProductsDB = new ProductsDB();
ProductDetail myProduct = myProductsDB.Ge tProduct(Produc tID);
lblFoundIn.Text = myProduct.produ ctFoundIn;
lblProductIdent ifier.Text = myProduct.produ ctIdentifier;
lblProductName. Text = myProduct.produ ctName;
lblUnitCost.Tex t = myProduct.unitC ost;

bool getOnlyActivePr oductColors = false;
DataSet ProductColors = myProductsDB.Ge tProductColors( ProductID,
getOnlyActivePr oductColors);
DataGrid1.DataS ource = ProductColors;
DataGrid1.DataB ind();

//Find the ModuleTitle and set its EditUR:
ModuleTitle1.Ed itUrl = "CA_EditProduct Color.aspx?Prod uctID=" + ProductID + "&ProductNa me=" + myProduct.produ ctName;

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.DataGrid1. PageIndexChange d += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.DataGrid1_Pa g eIndexChanged);
this.lnkBack.Cl ick += new System.EventHan dler(this.lnkBa ck_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void lnkBack_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct(ViewState["URLReferre r"].ToString());
}

private void DataGrid1_PageI ndexChanged(obj ect source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
DataGrid1.Curre ntPageIndex = e.NewPageIndex;
PoplulateProduc tRelatedInfo((i nt)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
472
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. The only way around I can think of is to test if the ID column is null any time a cells in a row is being edited, but it seems like the wrong way about it to perform that test for any edit in any row.
0
1977
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 dataset then should reflect all the details put into the xsd? Somewhere down the line there is not a 1:1 relationship. Be it that .NET is so tightly coupled to xsd, xml and dataset I would have expected any discrepancies to have been well documented and...
2
2032
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 level. Is this expected? Shouldn't anything on the properties window render accordingly? Thanks
1
3296
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 days of struggling, I figure asking you all (the experts) will keep me from going down some dark and dangerous road. The project I have is a fairly simple one, in theory anyway. The gist is to create a page where the user enters an IDNumber,...
1
5291
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 the user doesn't have to scroll horizontally. Essentially, I want to wrap a datagrid row (not text in individual columns) with as much control as possible. Make sense? While this seems simple enough on the surface, I can't figure out how to do...
6
1795
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
3378
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. I am an old VB6 coder used to using Sheridan controls, and I am just starting to learn the .net world. I am upgrading my music catalogue database, where the data is stored in an Access mdb file.
7
15004
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 MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
7
2040
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 (http://www.windowsformsdatagridhelp.com/default.aspx?ID=4bfab32d-9cff-4f5c-ba95-49bb9074a8bc), but I get no alignment at all when calling the class. George Shephard's site, while imminently useful, does not have an anwer for this issue.
8
3086
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 reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly on my DataGrid but I'm not sure how to get Crystal Reports 10 to use as its datasource the dataset...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10036
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9855
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.