473,466 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

possible .NET 2 compatability issue

bne
Hi All,

I have a shopping cart app that (I think) has broken due to an upgrade
to .NET 2.0.

Some products display fine:
<http://ukweddinggroup.com/default.aspx?prd=11>

Others display okay but validation on the dropdown list options break:
<http://ukweddinggroup.com/default.aspx?prd=249>

And still others completely wipe out with "System.ArgumentException: An
entry with the same key already exists":
<http://ukweddinggroup.com/default.aspx?prd=420>

The drop down list controls are created dynamically depending on what
options are available for each product in the database.

I'm presuming that there is a bug somewhere that was forgiven by .NET
1.1 but has now cropped up in .NET 2.0

The code that the runtime error objects to is:
System.ArgumentException: An entry with the same key already exists.

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

@&nbsp;<span id="itemPriceIndicator"><%= this.ItemPrice.ToString("c")
%></span></strong></span>

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

ItemPrice is from an overridden page control used across the site:

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

public decimal ItemPrice
{
get
{
object o = ViewState["ItemPrice"];
if(o == null)
{
return 0.0M;
}
return (decimal)o;
}
set
{
ViewState["ItemPrice"] = value;
}
}

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

The code where I think something is going wrong is:

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

private void rptProductOptions_ItemCreated(object sender,
RepeaterItemEventArgs e)
{
if(e.Item != null && (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem))
{
PlaceHolder plh = (PlaceHolder)e.Item.FindControl("plhControl");
DataSet dsProductOptionData = this.ProductOptionData();
DataRow drOptionGroup =
dsProductOptionData.Tables["OptionGroup"].Rows[e.Item.ItemIndex];
DataView dvOptions = new DataView(
dsProductOptionData.Tables["Option"],
String.Format("OptionGroupID = {0}", drOptionGroup["ID"]),
"Incidence",
DataViewRowState.OriginalRows);

// JS price array
foreach(DataRowView drv in dvOptions)
{
RegisterArrayDeclaration("aPrice", drv["Price"].ToString());
}

bool mandatory = Convert.ToBoolean(drOptionGroup["Mandatory"]);
HYL.Cart.OptionGroupType type =
(HYL.Cart.OptionGroupType)Enum.Parse(typeof(HYL.Ca rt.OptionGroupType),
drOptionGroup["Type"].ToString());
RequiredFieldValidator rfv;

if(type == OptionGroupType.List || type ==
OptionGroupType.MultipleList)
{
#region Lists
// display checkbox as only 1 option
if(dvOptions.Count == 1)
{
CheckBox cbx = new CheckBox();
if(mandatory)
{
cbx.Checked = true;
cbx.Enabled = false;
this.ItemPrice += Convert.ToDecimal(dvOptions[0]["Price"]);
}
else
{
cbx.Attributes.Add("onclick", "UpdatePrice();");
}
cbx.Text = dvOptions[0]["Description"].ToString();
cbx.CssClass = "ProductOption";

plh.Controls.Add(cbx);
}
else if(dvOptions.Count > 1) // display drop down list/listbox
{
if(type == HYL.Cart.OptionGroupType.MultipleList)
{
ListBox lbx = new ListBox();
lbx.Attributes.Add("onchange", "UpdatePrice();");
lbx.CssClass = "ProductOption";
lbx.Rows = 5;
lbx.SelectionMode = ListSelectionMode.Multiple;
lbx.DataTextField = "Description";
lbx.DataValueField = "ID";
lbx.DataSource = dvOptions;
lbx.DataBind();

plh.Controls.Add(lbx);

// to add client id after everything has finished databinding
lbx.PreRender += new EventHandler(lbx_PreRender);

if(mandatory)
{
rfv = new RequiredFieldValidator();
rfv.CssClass = "errText";
rfv.Display = ValidatorDisplay.Dynamic;
rfv.Text = "Please select an option.<br>";
rfv.ControlToValidate = lbx.ClientID;

plh.Controls.AddAt(0, rfv);
}
}
else
{
DropDownList ddl = new DropDownList();
ddl.Attributes.Add("onchange", "UpdatePrice();");
ddl.CssClass = "ProductOption";
ddl.DataTextField = "Description";
ddl.DataValueField = "ID";
ddl.DataSource = dvOptions;
ddl.DataBind();

plh.Controls.Add(ddl);

// to add blank option and client id after everything has
finished databinding
ddl.PreRender += new EventHandler(ddl_PreRender);

if(mandatory)
{
rfv = new RequiredFieldValidator();
rfv.CssClass = "errText";
rfv.Display = ValidatorDisplay.Dynamic;
rfv.Text = "Please select an option.<br>";
rfv.ControlToValidate = ddl.ClientID;
rfv.InitialValue = "0";

plh.Controls.AddAt(0, rfv);
}
}
}
#endregion
}
else if(type == OptionGroupType.IntegerInput || type ==
OptionGroupType.StringInput)
{
#region TextBoxes
TextBox txt = new TextBox();

if(type == OptionGroupType.IntegerInput)
{
txt.CssClass = "txtFieldSm";
}
else
{
txt.CssClass = "txtField";
txt.TextMode = TextBoxMode.MultiLine;
}

plh.Controls.Add(txt);
txt.PreRender += new EventHandler(txt_PreRender);

if(mandatory)
{
if(type == OptionGroupType.IntegerInput)
{
CompareValidator cmpv = new CompareValidator();
cmpv.CssClass = "errText";
cmpv.Display = ValidatorDisplay.Dynamic;
cmpv.Text = "Please enter a valid number.<br>";
cmpv.Type = ValidationDataType.Integer;
cmpv.Operator = ValidationCompareOperator.DataTypeCheck;
cmpv.ControlToValidate = txt.ClientID;

plh.Controls.AddAt(0, cmpv);
}
else
{
rfv = new RequiredFieldValidator();
rfv.CssClass = "errText";
rfv.Display = ValidatorDisplay.Dynamic;
rfv.Text = "Please enter a value.<br>";
rfv.ControlToValidate = txt.ClientID;

plh.Controls.AddAt(0, rfv);
}
}
#endregion
}
else if(type == OptionGroupType.DateInput)
{
#region Date Drop Downs

HYL.Web.Controls.DateDropDown ddd = new
HYL.Web.Controls.DateDropDown();
ddd.DateValue = DateTime.Today;
ddd.CalendarLinkText = "<img class=\"icoCalendar\" alt=\"calendar
select\" src=\"img/ico_calendar.gif\">";
ddd.CalendarPosition = 3;
ddd.CalendarStylePath = "@import 'Page/pfcal.css';";
ddd.DisplayFormat = "dMMMMyyyy";
ddd.ShowCalendar = true;
ddd.CssClass = "dateDropDown";
ddd.YearUpperBound = 3;

plh.Controls.Add(ddd);
ddd.PreRender += new EventHandler(ddd_PreRender);

if(mandatory)
{
DateTime minDate = DateTime.Today.AddDays(7);
ddd.DisabledDates = new HYL.Web.Controls.SelectionRange[] { new
HYL.Web.Controls.SelectionRange(DateTime.MinValue, minDate) };
ddd.DateValue = minDate;

HYL.Web.Controls.DateDropDownCompareValidator dcv = new
HYL.Web.Controls.DateDropDownCompareValidator();
dcv.CssClass = "errText";
dcv.Display = ValidatorDisplay.Dynamic;
dcv.Text = "Please enter a date at least 1 week from
today.<br>";
dcv.DateToCompare = minDate;
dcv.Operator = ValidationCompareOperator.GreaterThanEqual;
dcv.ControlToValidate = ddd.ClientID;

plh.Controls.AddAt(0, dcv);
}

#endregion
}
else if(type == OptionGroupType.None)
{
// do nothing
}
}
}

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

Anyone got an bright ideas?

Cheers

bne

Jul 1 '06 #1
0 1091

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

Similar topics

4
by: J Fisk | last post by:
Hi, I've been banging my head on the wall over this for about two days now so any thoughts are much appreciated. I have a static .svg file with embedded onclick="open()"'s all over. The svg...
5
by: BBeasley | last post by:
I've written severl dot net applications for users who use IE only. Now I'm developing one for a netscape user. My text boxes and lables resize in Netscape. Any ideas? Posted Via Usenet.com...
6
by: Nak | last post by:
Hi there, I was wondering if anyone knew of a way to maintain compatability with assemblies providing the interfaces remains the same? At the moment if I re-compile an assembly without actually...
3
by: Richard Cleaveland | last post by:
A client has just successfully upgraded from Access 97 to 2000. I don't have Access 2000, but I do have Office XP. Can I successfully use my Access on their database? They kind of did this...
0
by: SenthilVel | last post by:
hi I have my application built with Dotnet Framework 1.1 and now i can see most of clients having both the versions 2.0 and 1.1 in their systems, i get an issue when i run my 1.1 application . ...
0
by: David | last post by:
I am trying to migrate a .net 1.1 Web Application to a 2.0 Web Application. I am experiencing issues when putting a strongly typed dataset into session, and then navigation to a page where...
4
by: zak | last post by:
we have a suite of products that have a number of shared assemblies. During development and support the shared assemblies code will change . I want to control the versioning, so if the code chnages...
1
by: internet.system.error | last post by:
Hello, I write the casual Java code, and to make life easier at work I´ve decided to write a C# application that reads two excel files and does the usual number crunching and spits out a new file....
1
by: jsmall | last post by:
Hi, We currently have a fairly old product, which was originally only compatible with SQL 2000. When we upgraded our server to SQL 2005, the client product gave us a "This product is not...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.