Hi Frndz,
Functionality: Merge All columns with Message when no records in Gridview
To achieve this task,
Firs check DataTable value as above post.
After then check message condtion
if (dt.Rows[0][0].ToString() == "No Record(s) Found")
{
}
After then using ColumnSpan Property, merge all Cell value into single cell
gvBlockDetail.Rows[0].Cells[0].ColumnSpan = 3
After then remove other cell
gvBlockDetail.Rows[0].Cells.RemoveAt(i);
Check Below logic for more detail
Full Logic :
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count == 0)
{
dt.Rows.Add(new object[] { "No Record(s) Found" });
}
gvBlockDetail.DataSource = dt;
gvBlockDetail.DataBind();
if (dt.Rows[0][0].ToString() == "No Record(s) Found")
{
int cellCount = gvBlockDetail.Rows[0].Cells.Count;
gvBlockDetail.Rows[0].Cells[0].ColumnSpan = cellCount;
for (int i = cellCount - 1; i > 0; i--)
{
gvBlockDetail.Rows[0].Cells.RemoveAt(i);
}
}
Hope this helpful!
Thanks