Any control can be made invisible by setting its "Visible" property to
false. You can check whether your data source has any rows and set the
DataGrid's "visible" property to false if it does. For example:
ASP.Net:
<asp:Label id="lblNoRows" runat="server" visible="false">No
Results</asp:Label><br>
<asp:DataGrid id="dgData" runat="server" />
C# Code Behind:
private void Page_Load(object sender, System.EventArgs e)
{
DataTable dtSource;
//Code here retrieves data from data source into dtSource
if (dtSource.Rows.Count == 0)
lblNoRows.Visible = true;
else
{
dgData.DataSource = dtSource;
dgData.DataBind();
}
}
--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
Hi,
when there are no rows to display in my asp.net datagrid control, I'd like
to put in a message saying "No results" or some such
Ideally I'd like the message to be centred across all the columns, but I'd
settle for the message appearing in a single cell, or header/footer line.
maybe there's a way to make the whole control invisible when there are no
rows in the data source.
TIA for any ideas
Andy