Sunday, 11 December 2011

empty gridview display Header and footer

private void ShowNoResultFound(DataTable source, GridView gv)
{
    source.Rows.Add(source.NewRow()); // create a new blank row to the DataTable
    // Bind the DataTable which contain a blank row to the GridView
    gv.DataSource = source;
    gv.DataBind();
    // Get the total number of columns in the GridView to know what the Column Span should be
    int columnsCount = gv.Columns.Count;
    gv.Rows[0].Cells.Clear();// clear all the cells in the row
    gv.Rows[0].Cells.Add(new TableCell()); //add a new blank cell
    gv.Rows[0].Cells[0].ColumnSpan = columnsCount;
    //set No Results found to the new added cell
    gv.Rows[0].Cells[0].Text = "NO RESULT FOUND!";

}

       

No comments:

Post a Comment