CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.commerce_starter_kit Tags:
Item Type: NewsGroup Date Entered: 11/12/2003 8:06:21 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 156 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
chuke
Asp.Net User
Drop Down List - Page Postback11/12/2003 8:06:21 PM

0/0

I have modified the kit so that I have a DropDownList that houses the size(s) of each product... I am using the SDK version of the C# Cart Kit

The list is populated form the DB, then if the Size2 thru Size7 fields are NOT blank the list is thrown into the DropDownList... (so that I don't have NULL values in the DDL)

My problem is that when I get the page (all of the available sizes show up) I can choose another size, but the page posts back with the original value as the selected one?

I have looked at the processes that the page goes thru, so I think I have it in the right place, but am not for sure...

Here is the code... (the entire page)

-------------------------------------------------------------------------------------------------

<%@ Page Language="C#" EnableViewState="True" %>
<%@ Register TagPrefix="ASPNETCommerce" TagName="ReviewList" Src="_ReviewList.ascx" %>
<%@ Register TagPrefix="ASPNETCommerce" TagName="AlsoBought" Src="_AlsoBought.ascx" %>
<%@ Register TagPrefix="ASPNETCommerce" TagName="Menu" Src="_Menu.ascx" %>
<%@ Register TagPrefix="ASPNETCommerce" TagName="Header" Src="_Header.ascx" %>
<%@ outputcache duration="1" varybyparam="ProductID" %>
<script runat="server">

//*******************************************************
//
// The Page_Load event on this page is used to obtain
// product information from a database and then update
// UI elements with them.
//
// Note that this page is output cached at 1 minute
// intervals. This eliminates the need to hit the database
// on each request to the page.
//
//*******************************************************

void Page_Load(Object sender, EventArgs e)
{

// Obtain ProductID from QueryString
int ProductID = Int32.Parse(Request.Params["ProductID"]);

// Obtain Product Details
ASPNET.StarterKit.Commerce.ProductsDB products = new ASPNET.StarterKit.Commerce.ProductsDB();
ASPNET.StarterKit.Commerce.ProductDetails myProductDetails = products.GetProductDetails(ProductID);

// Update Controls with Product Details if NOT postback
if(!Page.IsPostBack){

string strSelectedSize ="";

//Declare variables for DDL

string SizeOne = myProductDetails.Size1;
string SizeTwo = myProductDetails.Size2;
string SizeThree = myProductDetails.Size3;
string SizeFour = myProductDetails.Size4;
string SizeFive = myProductDetails.Size5;
string SizeSix = myProductDetails.Size6;


//Declare Array for DDL
ArrayList SizeAry = new ArrayList();

SizeAry.Add(SizeOne);

if(SizeTwo != ""){
SizeAry.Add(SizeTwo);
}
if(SizeThree != ""){
SizeAry.Add(SizeThree);
}
if(SizeFour != ""){
SizeAry.Add(SizeFour);
}
if(SizeFive != ""){
SizeAry.Add(SizeFive);
}
if(SizeSix != ""){
SizeAry.Add(SizeSix);
}

Size.DataSource = SizeAry;
Size.DataBind();
strSelectedSize = Size.Items[0].Text;
Size.SelectedIndex = 0;

desc.Text = myProductDetails.Description;
UnitCost.Text = String.Format("{0:c}", myProductDetails.UnitCost);
ModelName.Text = myProductDetails.ModelName;
ModelNumber.Text = myProductDetails.ModelNumber.ToString();
Color.Text = myProductDetails.Color.ToString();
ProductImage.ImageUrl = "ProductImages/" + myProductDetails.ProductImage;
addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" + ProductID + "&Size=" + Size.SelectedValue;
ReviewList.ProductID = ProductID;
AlsoBoughtList.ProductID = ProductID;

}

}

void Size_SelectedIndexChanged(object sender, EventArgs e) {

string strSelectedSize = Size.SelectedItem.Text;

}

</script>
<html>
<head>
<link href="ASPNETCommerce.css" type="text/css" rel="stylesheet" />
</head>
<body bottommargin="0" leftmargin="0" background="images/sitebkgrd.gif" topmargin="0" rightmargin="0" marginheight="0" marginwidth="0">
<form runat="server">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td colspan="2">
<ASPNETCommerce:Header id="Header1" runat="server"></ASPNETCommerce:Header>
</td>
</tr>
<tr>
<td valign="top" width="145">
<ASPNETCommerce:Menu id="Menu1" runat="server"></ASPNETCommerce:Menu>
<img height="1" src="images/1x1.gif" width="145" />
</td>
<td valign="top" align="left">
<table height="100%" cellspacing="0" cellpadding="0" width="620" align="left" border="0">
<tbody>
<tr valign="top">
<td>
<br />
<img src="images/1x1.gif" width="24" align="left" />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td class="ContentHead">
<img height="32" src="images/1x1.gif" width="60" align="left" /> <asp:Label id="ModelName" runat="server"></asp:Label>
<br />
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="0" width="100%" border="0" valign="top">
<tbody>
<tr valign="top">
<td rowspan="2">
<img height="1" src="images/1x1.gif" width="24" />
</td>
<td width="309">
<img height="15" src="images/1x1.gif" />
<br />
<asp:image id="ProductImage" runat="server" border="0" width="309" height="185"></asp:image>
<br />
<br />
<img height="20" src="images/1x1.gif" width="72" /><span class="UnitCost">Your
Price:
&nbsp;<asp:Label id="UnitCost" runat="server"></asp:Label>
<br />
<img height="20" src="images/1x1.gif" width="72" />Color:<asp:Label id="Color" runat="server"></asp:Label></span><span class="Color">&nbsp;</span><span class="Size">&nbsp;</span><span class="QtyOnHand">&nbsp;</span>
<br />
<img height="20" src="images/1x1.gif" width="72" /><span class="ModelNumber">Model
Number:
&nbsp;<asp:Label id="ModelNumber" runat="server"></asp:Label> </span>
<br />
<img height="30" src="images/1x1.gif" width="72" />
<asp:hyperlink id="addToCart" runat="server" ImageUrl="images/add_to_cart.gif"></asp:hyperlink>
</td>
<td>
<table width="300" border="0">
<tbody>
<tr>
<td valign="top">
<asp:Label class="NormalDouble" id="desc" runat="server"></asp:Label>
<br />
</td>
</tr>
</tbody>
</table>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label id="Label1" runat="server" font-bold="True" font-names="Verdana" font-size="12pt" forecolor="Maroon" font-underline="True">Choose
Your Size</asp:Label>
</p>
<p>
&nbsp;<img height="5" src="images/1X1.gif" width="36" /><asp:Label id="SizeLabel" runat="server" font-names="Verdana" font-size="10pt">Size: </asp:Label>
<asp:DropDownList id="Size" runat="server" OnSelectedIndexChanged="Size_SelectedIndexChanged" AutoPostBack="True" EnableViewState="True"></asp:DropDownList>
<br />
<br />
<br />
<ASPNETCommerce:AlsoBought id="AlsoBoughtList" runat="server"></ASPNETCommerce:AlsoBought>
</p>
</td>
</tr>
</tbody>
</table>
<table border="0">
<tbody>
<tr>
<td>
<img height="20" src="images/1X1.gif" width="89" />
</td>
<td width="100">
<ASPNETCommerce:ReviewList id="ReviewList" runat="server"></ASPNETCommerce:ReviewList>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>


clacticfray
Asp.Net User
Re: Drop Down List - Page Postback8/10/2004 4:54:09 PM

0/0

Did you ever get this worked out? I am trying to add sizes as well.
I am using the VB version and am able to get the drop down to show up but am having trouble getting any code to execute beyond the page load that would allow me to update the addToCart.NavigateUrl value.
When I get home tonight I'm interested to see if the tags
AutoPostBack="True" and EnableViewState="True" that you have in your drop down will help me out.

Are you using Code-Behind?
Is the sub Size_SelectedIndexChanged on the code-behind page or on the ProductDetails Page itself.

Thanks
clacticfray
Asp.Net User
Re: Drop Down List - Page Postback8/11/2004 7:07:28 AM

0/0

okay, I've recreated this behavior... When I make a change in the drop down, the page reposts and I end up with the original values.

When I remove the Autopostback element of the drop down box, I'm able to select a new value, however, I'm not able to get the OnSelectedIndexChange event to fire.

Anyone know how/why?
thanks
andreinho
Asp.Net User
Re: Drop Down List - Page Postback8/11/2004 3:20:03 PM

0/0

first of all sorry for my bad english, however,
i've the same problem, i use a vb.net version's and don't work with or without Autopostback=true, onselectedindexchange event not work
i hope that anyone had a idea!!
bye at all!!
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning Visual Web Programming in VB .NET: From Novice to Professional Authors: Daniel Cazzulino, Craig Bowes, Victor Garcia Aprea, Mike Clark, James Greenwood, Chris Hart, Pages: 648, Published: 2005
Programming ASP.NET: Building Web Applications and Services Using C and VB.NET. Authors: Jesse Liberty, Dan Hurwitz, Pages: 988, Published: 2003
Build Your Own ASP.NET Website Using C# & VB.NET Authors: Zak Ruvalcaba, Pages: 746, Published: 2004
ASP.NET 2.0 All-In-One Desk Reference For Dummies: all-in-one desk reference for dummies Authors: Doug Lowe, Jeff Cogswell, Ken Cox, Pages: 910, Published: 2006
MCAD Developing and Implementing Web Applications with Microsoft Visual C#(TM) . NET and Microsoft Visual Studio(R) . NET Exam Cram 2 (Exam Cram 70-315): Exam Cram 2, McAd Exam 70-315 Authors: Kirk Hausman, Amit Kalani, Ed Tittel, Pages: 600, Published: 2003
Beginning ASP.NET 3.5 in VB 9.0: From Novice to Professional Authors: Matthew MacDonald, Pages: 1149, Published: 2007
Beginning ASP.NET 2.0 AJAX: Written and Tested with the Final 1.0 Release Version of ASP.NET AJAX for ASP:NET 2.0 Authors: Wallace B. McClure, Paul Glavich, Scott Cate, Steve C. Orr, Craig Shoemaker, Steven A. Smith, Jim Zimmerman, Pages: 344, Published: 2007
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
ASP.NET 2.0 Web Parts in Action: Building Dynamic Web Portals Authors: Darren Neimke, Pages: 324, Published: 2007

Web:
Web page Drop down list populating - .NET VB One - The code populating the dropdown list is NOT in an: If NOT Page.IsPostBack THEN End If if so then the list is getting populated every ...
p2p.wrox.com Forums - Post Back Required For Drop Down List p2p.wrox.com Forums - post back required for drop down list. ... I will try to help you where the problem lies. Go to Top of Page ...
Drop Down List doesn't post back after first post back - Stack ... UltraWebGrid: How to use a drop-down list in a column ... Redirecting users from edit page back to calling page · ASP.NET absolute path back to web-relative ...
cross page postback and cascading dropdown - ASP.NET Forums Re: cross page postback and cascading dropdown ... I have a list of probably a couple hundred items, that will show and hide based on the ...
cross page postback and cascading dropdown - ASP.NET Forums Re: cross page postback and cascading dropdown ... I have a list of probably a couple hundred items, that will show and hide based on the ...
Dropdown List - reverting to wrong item on postback : dropdown ... If not page.ispostback then 'initialize the form End if So that shouldn't be affecting a postback. I have the dropdown list setup to do an auto-postback. ...
Displaying drop-down list boxes for every row in a DataGrid \ Repe Reload this Page Displaying drop-down list boxes for every row in a ... • When the user will post back the form I would like to refer to ...
.NET Questions - Persisting dropdown selection through postback Then the page can just use the selection from the previous page to fetch the right ... There is a flaw in the dropdown list control in ASP. ...
Drop down list losing value on postback - telerik Forum I prepared a sample page based on the code you have sent us, however, the selected value in the dropdown was not lost on my side when I made ...
Re: Accessing dropdown list selected value on postback with ... Jun 15, 2007 ... Re: Accessing dropdown list selected value on postback with ... I have a web page containing a dropdownlist containing thousands of entries. ...




Search This Site:










button

multiple sites on one database.

stop/start windows services via webpage

using a calendercontrol file in a userwizard

asp.net beginner

grid view(edit item template portion)

suddenly my web run very slow.

multiple databound objects for one database column.

get value from user control

user account setup w/o permission

method not found: void system.web.ui.webcontrols...

how to know object is instantiate or not

postback problems

asp training?

what is my assembly name (for httphandler's web.config declaration)

c# session varibles

vb.net & c# pages under virtual directory

ms access database connection

updating db from text feilds

need help, this is giving me stress.

advice required

trim string to fit in fixed width table cell [edited by adec, moderator]

how to create this layout dynamically.

radiobuttonlist - listitem background color ???

help multiple select

cookies (does one exist?)

limitation in prozedure variables

path from including an .ascx file (simple issue)

javascript and vs2005

publish a aspx webpage

  Privacy | Contact Us
All Times Are GMT