Insert new row in gridview when no data in gridview
sql = "select * from tblbkdetails where formid='" + formid + "'";
ds = SqlHelper.ExecuteDataset(Cnn, CommandType.Text, sql);
//grdshow.DataSource = ds.Tables[0];
//grdshow.DataBind();
if (ds.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
GridView2.DataSource = ds;
GridView2.DataBind();
int columncount = GridView2.Rows[0].Cells.Count;
GridView2.Rows[0].Cells.Clear();
GridView2.Rows[0].Cells.Add(new TableCell());
GridView2.Rows[0].Cells[0].ColumnSpan = columncount;
GridView2.Rows[0].Cells[0].Text = "There is no Records ";
}
ds = SqlHelper.ExecuteDataset(Cnn, CommandType.Text, sql);
//grdshow.DataSource = ds.Tables[0];
//grdshow.DataBind();
if (ds.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
GridView2.DataSource = ds;
GridView2.DataBind();
int columncount = GridView2.Rows[0].Cells.Count;
GridView2.Rows[0].Cells.Clear();
GridView2.Rows[0].Cells.Add(new TableCell());
GridView2.Rows[0].Cells[0].ColumnSpan = columncount;
GridView2.Rows[0].Cells[0].Text = "There is no Records ";
}
Comments
Post a Comment