[Solved] ASP.Net Error: Operator '<' cannot be applied to operands of type 'string' and 'int'

kankon
 
on Sep 01, 2020 11:33 PM
4379 Views

hello,

i need help with calculate with if conditions statements 

i have label with number

if this number = 0 ~14 then - the total

if this number = 15 or more then - the total

I am trying with this code but getting error 

Operator '<' cannot be applied to operands of type 'string' and 'int'

if (Label_day.Text < 15)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 35 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}
else if (Label_day.Text 20)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 45 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Sep 02, 2020 12:01 AM
kankon says:
if (Label_day.Text < 15)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 35 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}
else if (Label_day.Text  20)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 45 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}

Replace with below code.

if (Convert.ToInt32(Label_day.Text) < 15)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 35 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}
else if (Convert.ToInt32(Label_day.Text) >= 15)
{
    gvFiles.FooterRow.Cells[3].Text = ("Total", 45 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}