I don't really understand what you want to achieve but the only thing I see is extremely redundant code. The inner for each loop is included three times.
And this code:
string mbetxt = ((TextBox)item0.FindControl("txtMBE")).Text;
if (mbetxt.ToString() == "Yes")
{
foreach (RepeaterItem item1 in Repeater1.Items)
{
string amount = ((TextBox)item1.FindControl("txtAmount")).Text;
totalamount = int.Parse(Amount.Text);
subamount = subamount + int.Parse(amount.ToString());
}
}
else
{
foreach (RepeaterItem item1 in Repeater1.Items)
{
string amount = ((TextBox)item1.FindControl("txtAmount")).Text;
totalamount = int.Parse(Amount.Text);
subamount = subamount + int.Parse(amount.ToString());
}
}
Does it really matter if mbetxt is Yes or something else? I think whatever the idea is, it would be much more easy to first divide it up into chunks and use those function to perform the actual task. In the inner loop you also use amount and Amount, is this really the most clear? Your code is already pretty long, unclear and not a single part can be reused. Further it is prone to errors because it's hard to maintain and almost even harder to test. You could make a function for the inner loop like SumRepeaterItems, this is also more self documenting and can be tested apart from the rest. You could then use it in your code three times, shortening it drastically and get more overview. Well, just some pointers to inspire your coding :)
Good luck!