If no record in GridView display a runtime emplty GridView

Santosh0683
Posted by Santosh0683 under ASP.NET category on | Points: 40 | Views : 3448
This example show when we use GridView and there is functionality Edit.Delete and Add New row using footer row.
If there is no record in database so it good to display a runtime emplty grid.
call this method like this...
Ds = objempBLL.GetEmp();
if (Ds.Tables[0].Rows.Count > 0)
{
gridview.DataSource = Ds;
gridviewDataBind();
}
else
{
ShowNoResultFound(Ds, gridview);
}
private void ShowNoResultFound(DataSet ds,GridView gv)
{
DataTable dt = (DataTable)ds.Tables[0];
dt.Rows.Add(dt.NewRow());
gv.DataSource = dt;
gv.DataBind();
int TotalColumns = gv.Rows[0].Cells.Count;
gv.Rows[0].Cells.Clear();
gv.Rows[0].Cells.Add(new TableCell());
gv.Rows[0].Height = 0;
gv.Rows[0].Visible = false;
}

Comments or Responses

Posted by: Lakhangarg on: 8/24/2010 Level:Silver | Status: [Member] [Moderator] | Points: 10
Hi Santosh,

It will be better if you can provide some description about each step.. it will be easy for the user to understand.

Regards,
Lakhan Pal Garg

Login to post response