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("");
htmlTable.Append("Sr. Name Status Action ");
htmlTable.Append("");
foreach (DataRow row in dt.Rows)
{
String Status = "Blocked";
if (Convert.ToBoolean(row["status"]))
{
Status = "Active";
}
htmlTable.Append("");
htmlTable.Append("" + Count.ToString() + " ");
htmlTable.Append("" + row["description"] + " ");
htmlTable.Append("");
htmlTable.Append(" ");
Count++;
}
htmlTable.Append("");
htmlTable.Append("
");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });
Thanks
Jithu ThomasPosted Aug 25, 2024, 9:33 AM
To display "No Record Found" when there are no records in your DataTable (
dt), you can check ifdt.Rows.Countis zero before building the table. If there are no rows, you can add a message to the placeholder instead. Here's how you can modify your code to include this check: