locked
What the ?!?!? (please help) RRS feed

  • Question

  • C# with this....

     int outsideLabourHrsReg;
     int internalLabourHrsReg;

    Code & conversion works fine for.....

     outsideLabourHrsReg += Convert.ToInt32(e.Row.Cells[15].Text);

    BUT I get

    "Input string was not in a correct format" error when attempting below line of code immediately after!!!!!!!!!!!!

     internalLabourHrsReg += Convert.ToInt32(e.Row.Cells[15].Text);

    what gives?!?!?! Help!

    Thursday, December 28, 2006 9:19 PM

Answers

  • Well, due to the "if (labourType.Substring(0, 2).Contains("C"))" we never do both the line you quoted in you first message at the same time, so we can't say that one works and the other doesn't.  In fact, from looking at the code, all I can say for sure about the data is that e.Row.Cells[14].Text is "TB" (and that e.Row.Cells[17].Text does NOT have a"C" in it's first two characters.)  What we really need to know is exactly what is in e.Row.Cells[15].Text

     

    Thursday, December 28, 2006 11:02 PM

All replies

  • Clearly "e.Row.Cells[15].Text);"  has changed somehow between the two lines.  Show us the full block of code and the value of "e.Row.Cells[15].Text" and we'll see what we can do.
    Thursday, December 28, 2006 9:38 PM
  • if (e.Row.Cells[14].Text == "TB") // determine if labour & labour hrs is contractor or internal

    {

    string labourType;

    labourType = e.Row.Cells[17].Text; // = EMPLOYEE_CODE from dB.

    if (labourType.Substring(0, 2).Contains("C")) // if true, this is a contractor or outside labour

    {

    e.Row.Cells[9].Text = "Regular:&nbsp; &nbsp;" + e.Row.Cells[15].Text + "<br/>Premium: " + e.Row.Cells[16].Text; // outside labour hours

    outsideLabourHrsReg += Convert.ToInt32(e.Row.Cells[15].Text);

    outsideLabourHrsPrem += Convert.ToInt32(e.Row.Cells[16].Text);

    e.Row.Cells[10].Text = e.Row.Cells[13].Text; // outside labour $

    outsideLabourDollars += Convert.ToDecimal(e.Row.Cells[10].Text);

    }

    else // non contractor ergo internal labour

    {

    e.Row.Cells[11].Text = "Regular:&nbsp; &nbsp;" + e.Row.Cells[15].Text + "<br/>Premium: " + e.Row.Cells[16].Text; // internal labour hours

    internalLabourHrsReg += Convert.ToInt32(e.Row.Cells[15].Text);        <<<<<<<<<<<<<< ERROR

    internalLabourHrsPrem += Convert.ToInt32(e.Row.Cells[16].Text);

    e.Row.Cells[12].Text = e.Row.Cells[13].Text; // internal labour $

    internalLabourDollars += Convert.ToDecimal(e.Row.Cells[12].Text);

    }

    }

    Thursday, December 28, 2006 9:54 PM
  • Well, due to the "if (labourType.Substring(0, 2).Contains("C"))" we never do both the line you quoted in you first message at the same time, so we can't say that one works and the other doesn't.  In fact, from looking at the code, all I can say for sure about the data is that e.Row.Cells[14].Text is "TB" (and that e.Row.Cells[17].Text does NOT have a"C" in it's first two characters.)  What we really need to know is exactly what is in e.Row.Cells[15].Text

     

    Thursday, December 28, 2006 11:02 PM
  • Well thanks for the help. It's all fixed
    Saturday, December 30, 2006 1:26 AM