When no records in a DataGrid how to show a default alternative message?

Discussion in 'ASP .Net' started by Randall Parker, Nov 9, 2005.

  1. Title says it all. Using ASP.Net v1.1. Want to show some message when there are no
    records to show in a grid. Does one do that with the DataGrid control itself? Or in
    CodeBehind should one conditionally fill in a label control only when one tests and
    sees the resultset of a query is empty?

    How do you handle this case?
     
    Randall Parker, Nov 9, 2005
    #1
    1. Advertisements

  2. You could check the DataTable.Rows.Count to see if it carries values and not
    display/bind the datagrid if it doesn't, or bind and hide the datagrid if
    the DataGrid.Items.Count is zero. Of course any of those checks would allow
    you to populate and show a conditional label with appropriate text.

    --
    Regards

    John Timney
    ASP.NET MVP
    Microsoft Regional Director
     
    John Timney \( MVP \), Nov 9, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.