Click here to Skip to main content
15,906,567 members
Home / Discussions / C#
   

C#

 
GeneralRe: XML, XSD VALIDATION Pin
waqasm2-Oct-09 3:56
waqasm2-Oct-09 3:56 
GeneralRe: XML, XSD VALIDATION Pin
Henry Minute2-Oct-09 5:29
Henry Minute2-Oct-09 5:29 
GeneralRe: XML, XSD VALIDATION Pin
waqasm7-Oct-09 6:14
waqasm7-Oct-09 6:14 
QuestionSqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 6:22
hande541-Oct-09 6:22 
AnswerRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 7:07
professionalMd. Marufuzzaman1-Oct-09 7:07 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 7:57
hande541-Oct-09 7:57 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 8:29
professionalMd. Marufuzzaman1-Oct-09 8:29 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 8:50
hande541-Oct-09 8:50 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Abhishek Sur1-Oct-09 10:31
professionalAbhishek Sur1-Oct-09 10:31 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 10:33
hande541-Oct-09 10:33 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 20:15
professionalMd. Marufuzzaman1-Oct-09 20:15 
Questionsocket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 5:49
TimWallace1-Oct-09 5:49 
AnswerRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 6:22
sitebuilderLuc Pattyn1-Oct-09 6:22 
GeneralRe: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 6:56
TimWallace1-Oct-09 6:56 
GeneralRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 7:09
sitebuilderLuc Pattyn1-Oct-09 7:09 
General[SOLVED] Re: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 8:34
TimWallace1-Oct-09 8:34 
GeneralRe: [SOLVED] Re: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 8:41
sitebuilderLuc Pattyn1-Oct-09 8:41 
QuestionMethod not calculating properly‏ Pin
Marcus Farrugia1-Oct-09 5:09
Marcus Farrugia1-Oct-09 5:09 
AnswerRe: Method not calculating properly‏ [modified] Pin
harold aptroot1-Oct-09 5:22
harold aptroot1-Oct-09 5:22 
GeneralRe: Method not calculating properly‏ Pin
PIEBALDconsult1-Oct-09 15:31
mvePIEBALDconsult1-Oct-09 15:31 
AnswerRe: Method not calculating properly‏ Pin
Luc Pattyn1-Oct-09 5:34
sitebuilderLuc Pattyn1-Oct-09 5:34 
AnswerRe: Method not calculating properly‏ Pin
J4amieC1-Oct-09 6:32
J4amieC1-Oct-09 6:32 
Well your code is a bit of a mess. As Luc has pointed out, ASP.NET will reset each of those class variables to zero on postback. There is the option of persisting values between postbacks but a more elegant solution would be to calculate the price whenever you need it.

I would approach this as follows, start with a method to do the actual proce calculation

private decimal CalculatePrice()
{
  decimal sizePrice = 0;
  switch(rblSize.SelectedValue)
  {
    case "Slice": sizePrice = 8;break;
    case "Small": sizePrice = 10;break;
    // -- etc.
  }

  decimal ingredientsPrice = 0;
  for (int i = 0; i < cblIngredients.Items.Count; i++)
  {
    if (cblIngredients.Items[i].Selected)
    {
      ingredientsPrice ++;
    }
  }

  return sizePrice + ingredientsPrice ;
}


Next have this method called when either action is performed

protected void RadioButtonList1_SelectedIndexChanged1(object sender, EventArgs e)
{
  decimal totalPrice = CalculatePrice();
  lblPriceTotal.Text = totalPrice.ToString();
)

protected void cblIngredients_SelectedIndexChanged(object sender, EventArgs e)
{
  decimal totalPrice = CalculatePrice();
  lblPriceTotal.Text = totalPrice.ToString();
}

AnswerRe: Method not calculating properly‏ Pin
Keith Barrow1-Oct-09 7:05
professionalKeith Barrow1-Oct-09 7:05 
QuestionUploading pictures. Pin
Mix Wheels1-Oct-09 4:17
Mix Wheels1-Oct-09 4:17 
AnswerRe: Uploading pictures. Pin
Luc Pattyn1-Oct-09 4:22
sitebuilderLuc Pattyn1-Oct-09 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.