Ramco Ramco

Ramco Ramco

  • 441
  • 3.4k
  • 523.2k

Error - Not all code paths return value

Oct 6 2022 6:25 AM

Hi

 I am getting above error on BindTrainingModule

[WebMethod]
public static string BindTrainingModule(string TId)
{

    try
    {
        BALTrainingModule bALTrainingModule = new BALTrainingModule();
        List<TrainingModuleMaster> Result = bAL.GetRecordDetails(Convert.ToInt32(TId));
        if (Result != null)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(Int32));
            dt.Columns.Add("Name", typeof(string));
            foreach (var column in Result)
            {
                DataRow row = dt.NewRow();
                row["Id"] = column.ID;
                row["Name"] = column.Module + " / " + column.CourseName;
                dt.Rows.Add(row);
            }

            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("<option value=\"0\">Select</option>");
            foreach (DataRow dr in dt.Rows)
                stringBuilder.Append("<option value=\"" + dr["Id"] + "\">" + dr["Name"] + "</option>");
            return stringBuilder.ToString();
        }
    }
    catch (Exception ex)
    {
        return "0";
    }
}

Thanks


Answers (1)