Skip to content
Loading
  • 0
    @Nilesh Sawardekar 
    Thank you very much for your codes. I do learn some functions.
     
    @ Amit Mohanty
    It's amazing because you get directly in my understanding. It's perfectly what I was expecting. But there's something little bits confusing me.
    Its making very well the selecting between "textBoxes" I need. But the problem is Its cannot save if one more (or another textbox(es)) is or are be filled by numbers (positive or negative).
    For instance:
    1) On my "Form1" there are "TextBox1", "TextBox2", "TextBox3", "TextBox4"
    2) When I insert datas on "TextBox1" and "TextBox2" for example when I click on my Button its cant save if its find "TextBox3" or "TextBox4" filled.
    3) Should accept to save ONLY when its sees the ONLY "TextBoxes" filled.
    0
  • Amit Mohanty
    0
    Hey Israel i think this your condition when textBox1 and textBox2 are filled and textBox3 and textBox4 are empty then data save to database or when textBox1 and textBox2 are empty and textBox3 and textBox4 are filled then data save to database.

    Then your condition:
    1. if ((decimal.Parse(textBox1.Text) != 0 && decimal.Parse(textBox2.Text) != 0 &&   
    2.     string.IsNullOrEmpty(textBox3.Text) && string.IsNullOrEmpty(textBox4.Text)) ||  
    3.     (decimal.Parse(textBox3.Text) != 0 && decimal.Parse(textBox4.Text) != 0 &&   
    4.     string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text)))    
    5. {  
    6.     // Code to save data to database    
    7. } 
    0
  • Jes Sie
    0
    Use if else if:

    1. protected void Button3_Click(object sender, EventArgs e)  
    2.         {  
    3.             if (!string.IsNullOrEmpty(TextBox1.Text) && !string.IsNullOrEmpty(TextBox2.Text))  
    4.             {  
    5.                 //insert  
    6.             }  
    7.             else if(!string.IsNullOrEmpty(TextBox1.Text) && !string.IsNullOrEmpty(TextBox3.Text))  
    8.             {  
    9.                 //insert  
    10.             }  
    11.             
      Code
      else             {                 Button3.Enabled = false;             }

    12.         }  
    0
  • 0
    @Hold On
    Your codes was a big help for others functions I was looking for. Thanx!
     
    @Nilesh Sawardekar
    You are very welcome. Thank you again for the codes. 
     
    @Amit Mohanty
    On the last hour you do understand my idea. Many thank and learning is every days. I have been really suffocated to resolv it. Thank you again.
    0