Ramco Ramco

Ramco Ramco

  • 439
  • 3.4k
  • 544.1k

No Record Found

Aug 25 2024 9:15 AM

Hi

  I have below code . I want if there is no record then in placeholder or something like that it should display "No Recourd Found".

StringBuilder htmlTable = new StringBuilder();
htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");
htmlTable.Append("<thead><tr style='background-color:green;color:white; text-align: center;'><th>Sr.</th><th>Name</th><th>Status</th><th class='text-center nosort'>Action</th><th style='display:none'</th><th style='display:none'</th></tr></thead>");
htmlTable.Append("<tbody>");
foreach (DataRow row in dt.Rows)
{
    String Status = "Blocked";
    if (Convert.ToBoolean(row["status"]))
    {
        Status = "Active";
    }

    htmlTable.Append("<tr>");
    htmlTable.Append("<td>" + Count.ToString() + "</td>");
    htmlTable.Append("<td>" + row["description"] + "</td>");


    htmlTable.Append("<td style='display:none'>" + row["status"] + "</td>");
    htmlTable.Append("</tr>");
    Count++;
}
htmlTable.Append("</tbody>");
htmlTable.Append("</table>");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });

Thanks


Answers (1)