0

I'm working in a web application aspx and C#. I have two procedures in code behind.

protected void Button1_Click(object sender, EventArgs e)
{
...
int totalCost=1000;
Label7.Text = totalCost.ToString();
}

i have this code behind in in button2

protected void Button2_Click(object sender, EventArgs e)
{
...
int  bCost=Convert.ToInt32(Label7.Text);
}

I first click button 1 and all is OK when I click button 2 the exeption is thrown at

int  bCost=Convert.ToInt32(Label7.Text);

is
Input string was not in a correct format.

Why I can't use the Label7 value from second procedure.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by lighthead
0

It shouldn't normally happen. Check the value of the Label7 in Button2_Click when converting to int. Something must be changing the value of label7.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.