9
Answers

Convter in to Decmail In Textbox Value

shah Momin

shah Momin

2y
713
1
private void DutySpotButton_Click(object sender, EventArgs e)
        {


            Button button = sender as Button;
            lblSpotID.Text = button.Name;
            string[] strArray = button.Text.Split(new string[1]
            {
                Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                txtSpotName.Text = strArray[0];
                numMaxLimit.Text = (Decimal)int.Parse(strArray[1]);
                lblSpotRow.Text =tblDutySpot.GetRow((Control)button).ToString();
                lblSpotCol.Text =tblDutySpot.GetColumn((Control)button).ToString();
            if (button.BackColor == Color.Red)
            {
               rbtnOffSpot.Checked = true;
               rbtnOnSpot.Checked = false;
            }
            else
            {
               rbtnOnSpot.Checked = true;
               rbtnOffSpot.Checked = false;
            }
        }
C#

Line Number 11. numMaxLimit.Text = (Decimal)int.Parse(strArray[1]);

textboxn name = numMaxLimit.Text

Answers (9)
3
Sachin Singh

Sachin Singh

NA 55.8k 87.9k 2y
Yes we all were wrong use this
  1. numMaxLimit.Text =Convert.ToString(Convert.ToDecimal(strArray[1]));    
 
Accepted
4
Sachin Singh

Sachin Singh

NA 55.8k 87.9k 2y
Have you tested this?
 
  1. numMaxLimit.Text = Convert.ToDecimal(strArray[1]);  
3
Amit Mohanty

Amit Mohanty

16 52.2k 6.1m 2y
try this
  1. numMaxLimit.Text = Convert.ToDecimal(strArray[1]).ToString();    
  2. // or    
  3. numMaxLimit.Text = decimal.Parse(strArray[1]).ToString();  
3
Amit Mohanty

Amit Mohanty

16 52.2k 6.1m 2y
Hey you can use both Convert.ToDecimal() and decimal.Parse()
  1. numMaxLimit.Text = Convert.ToDecimal(strArray[1]);  
  2. // or  
  3. numMaxLimit.Text = decimal.Parse(strArray[1]); 
3
Gajendra Jangid

Gajendra Jangid

25 41.2k 2.3m 2y
CHeck with below line
  1. numMaxLimit.Text = Convert.ToDecimal(strArray[1]);  
 
2
shah Momin

shah Momin

NA 176 24.3k 2y
  1. ConfigurationBLL configurationBLL = new ConfigurationBLL();  
  2.   
  3.             if (lblSpotID.Text == "ID")  
  4.             {  
  5.                 int num1 = (int)MessageBox.Show("Please select a spot""Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);  
  6.             }  
  7.             else if (txtSpotName.Text == "")  
  8.             {  
  9.                 int num2 = (int)MessageBox.Show("Please enter a spot name""Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);  
  10.             }  
  11.             else if (numMaxLimit.Value < numMaxLimit.Minimum || numMaxLimit.Value > numMaxLimit.Maximum)  
  12.             {  
  13.                 int num3 = (int)MessageBox.Show("Please enter a valid spot max limit""Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);  
  14.             }  
  15.             else if (!rbtnOnSpot.Checked && !rbtnOffSpot.Checked)  
  16.             {  
  17.                 int num4 = (int)MessageBox.Show("Please mark on/off on selected spot""Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);  
  18.             }  
  19.             else  
  20.             {  
  21.                 int isOn = rbtnOnSpot.Checked ? 1 : 0;  
  22.                 configurationBLL.SaveDutySpot(int.Parse(lblSpotID.Text), txtSpotName.Text, (int)numMaxLimit.Value, isOn);  
  23.                 int row = int.Parse(lblSpotRow.Text);  
  24.                 Button controlFromPosition = (Button)tblDutySpot.GetControlFromPosition(int.Parse(lblSpotCol.Text), row);  
  25.                 controlFromPosition.Text = txtSpotName.Text + Environment.NewLine + (object)numMaxLimit.Value;  
  26.                 if (isOn == 1)  
  27.                     controlFromPosition.BackColor = Color.Green;  
  28.                 else  
  29.                     controlFromPosition.BackColor = Color.Red;  
  30.                 int num5 = (int)MessageBox.Show("Spot updated successfully""Duty Spot", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);  
Error On This Line
 
  else if (numMaxLimit.Value < numMaxLimit.Minimum || numMaxLimit.Value > numMaxLimit.Maximum)
 
   configurationBLL.SaveDutySpot(int.Parse(lblSpotID.Text), txtSpotName.Text, (int)numMaxLimit.Value, isOn);
 
controlFromPosition.Text = txtSpotName.Text + Environment.NewLine + (object)numMaxLimit.Value;
 
 
2
shah Momin

shah Momin

NA 176 24.3k 2y

Thank You For ALL

 

Sachin Singh Pm Message 

2
shah Momin

shah Momin

NA 176 24.3k 2y
YEs
 
2
shah Momin

shah Momin

NA 176 24.3k 2y
Cannot implicitly convert type 'decimal' to 'string'