[Solved] How could I compute the number from the database and show it to the Label everytime I change the combo box value?


This is, quite explicitly, a string:

dt.Tables[0].Rows[0]["SalaryGrade"].ToString()

A string is just text. You don’t perform math on it. If this string is guaranteed to be an integer, you can convert it directly:

lblHour.Text = (int.Parse(dt.Tables[0].Rows[0]["SalaryGrade"])/22/8);

If it’s not guaranteed, then you might want some error checking first:

int salaryGrade;
if (!int.TryParse(dt.Tables[0].Rows[0]["SalaryGrade"], out salaryGrade))
{
    // wasn't an integer, handle the error condition here
}
lblHour.Text = (salaryGrade/22/8);

Note: Integer division is going to result only in an integer. If you’re looking for decimal values, you’re going to want to convert your numbers to something with decimal precision. (Such as decimal, which also has .Parse() and .TryParse() methods of course.) Otherwise you may just end up with zeroes and not know why.

2

solved How could I compute the number from the database and show it to the Label everytime I change the combo box value?