How to set >= Condition in dropdown list using asp.net c#
Query:
C#
if (ddlToTimeHour >= ddlFromTimeHour)
{
query = "insert into ied_fsentry(fse_Unit,fse_Line,fse_Shift,fse_Date,fsm_Id,fse_Remarks,fse_From,fse_To,fse_EntryDate) values ('" + ddlUnit.SelectedValue + "','" + ddlLine.SelectedValue + "','" + ddlShift.SelectedValue + "', '" + values[2] + "-" + values[1] + "-" + values[0] + "','" + ddlLineStoppageReason.SelectedValue + "','" + txtRemarks.SelectedItem.Text + "','" + FromtimeString.ToString() + "','" + ToTimeString.ToString() + "',now())";
Console.WriteLine("Data Succesfuuly Inserted");
}
else
{
ShowMessage("Unable to save data. Please check entry.", MessageType.Error);
}

Salman BegRank #284 · 8.8K reputationPosted Jun 10, 2021, 4:12 AM EDT
If ddlToTimeHour and ddlFromTimeHour return either string then you can't apply a boolean operator to it. If your values in your dropdownlist are actually "true" and "false" Or int, then you can use it. See this link for example that how to use >=,
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/comparison-operators#greater-than-operator-