Below code will check that if there is no record in Data table than it will add a new row in data Grid to show a message that there is no Record in the DataTable.
Just Copy and past the Code.
Just Copy and past the Code.
grd_abc.DataSource = ds.Tables["abc"]; //added if (ds.Tables["abc"].Rows.Count < 1) { empty = true; ds.Tables["aging"].Rows.Add(ds.Tables["abc"].NewRow()); grd_abc.DataSource = ds.Tables["abc"]; grd_abc.DataBind(); int columncount = grd_abc.Rows[0].Cells.Count; grd_abc.Rows[0].Cells.Clear(); grd_abc.Rows[0].Cells.Add(new TableCell()); grd_abc.Rows[0].Cells[0].ColumnSpan = columncount; grd_abc.Rows[0].Cells[0].Text = " No Record Found "; grd_abc.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grd_abc.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Maroon; } else { grd_abc.DataBind(); }
No comments:
Post a Comment