Click here to Skip to main content
16,011,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help me adding textbox values

my code is having error

C#
protected void TextBox11_TextChanged(object sender, EventArgs e)
    {
        if((!string.IsNullOrEmpty(TextBox6.Text)) && (!string.IsNullOrEmpty(TextBox7.Text)) && (!string.IsNullOrEmpty(TextBox8.Text)) && (!string.IsNullOrEmpty(TextBox9.Text)) && (!string.IsNullOrEmpty(TextBox10.Text)) && (!string.IsNullOrEmpty(TextBox11.Text)))
        {
            TextBox12.Text = (Convert.ToInt32(TextBox6.Text) + Convert.ToInt32(TextBox7.Text)) + (Convert.ToInt32(TextBox8.Text) + Convert.ToInt32(TextBox9.Text)) + (Convert.ToInt32(TextBox10.Text) + Convert.ToInt32(TextBox11.Text)).ToString();
        }
    }

i want to add 6 textbox values and display in read only textbox7 please help me thanks in advance friends help me plz
Posted
Updated 19-Apr-12 4:14am
v2
Comments
[no name] 19-Apr-12 10:18am    
Knowing what the error is would be really helpful. If you really read what your code is doing and what you wrote here, you would easily see the problem....
"TextBox12.Text =" will not display anything in textbox7
Ed Nutting 19-Apr-12 10:20am    
My apologies - I opened too many tabs and posted that comment on the wrong question as a result :S
I agree with Wes Aday - please could you update your question with the error message (use Improve Question link - bottom right of question).
Thanks,
Ed

1 solution

i got it working i had did little error that converting fro int to string and correct code is below

if((!string.IsNullOrEmpty(TextBox6.Text)) && (!string.IsNullOrEmpty(TextBox7.Text)) && (!string.IsNullOrEmpty(TextBox8.Text)) && (!string.IsNullOrEmpty(TextBox9.Text)) && (!string.IsNullOrEmpty(TextBox10.Text)) && (!string.IsNullOrEmpty(TextBox11.Text)))
{
TextBox12.Text = ((Convert.ToInt32(TextBox6.Text) + Convert.ToInt32(TextBox7.Text)) + (Convert.ToInt32(TextBox8.Text) + Convert.ToInt32(TextBox9.Text)) + (Convert.ToInt32(TextBox10.Text) + Convert.ToInt32(TextBox11.Text))).ToString();
}
 
Share this answer
 

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