Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have work out most of my problems with your help thanks to all assisted.

I hope this is the last piece of code I need help with.


With my repeater creating dynamic text boxes I need to place percentages in the appropriate text box per newly created textbox:


I have this for the first one
double amount = Convert.ToDouble(textBox.Text);
double subamount = Convert.ToDouble(textBox1.Text);
double per = (subamount  / amount) * 100;
percentage.text = per.ToString();

this work well for the first line.

I repeated the process

foreach (RepeaterItem item in Repeater1.Items)
{
string mbe = ((TextBox).item.FindControl("txtMBE")).Text;
if (mbe.ToString() == "Yes")
{
  string txtamount = ((TextBox)item.FindControl("txtAmount").Text;
  string txtmpercent = ((TextBox)item.FindControl("txtMPercent").Text;
  double dynamicamount = Convert.ToDouble();
  double dynamicsubamount = Convert.ToDouble();
  double dynamicpercent = (dynamicsubamount / dynamicamount) * 100;

My problem is how to write this to show in each newly created textbox where the txtMpercent appears 

}

}

When I build and to test. I placed a break to check and stepping into I get to this point in the code it shows me that it is calculating on each box but not writing to the assigned textboxes.

(by the way the Yes/No are dropdownlist)

What and I doing wrong.

other using string to work in my application.
Posted

1 solution

You have:
double dynamicamount = Convert.ToDouble();
double dynamicsubamount = Convert.ToDouble();

You're not passing any values into Convert.ToDouble(), so that would be a problem, no? Is it compiling like this?

I think you just have to assign the value back to the textbox:
((TextBox)item.FindControl("txtAmount").Text = your_value


Cheers.
 
Share this answer
 
Comments
postonoh 17-Aug-10 9:33am    
Reason for my vote of 5
answer perfect

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900