Reputation: 5664
I have a datagrid in my program, where data is coming from a SQL stored procedure and columns names are autogenerated. Below is my xaml definition for datagrid.
When my page is loaded, stored procedure is executed and data is populated into this grid with headers.
For case where results are empty, I would like to show the header names and wanted to show a message to the user.
<DataGrid Name="datagrid"
Margin="12,77,52,156"
DataContext="{Binding}"
IsReadOnly="True"
Grid.RowSpan="2"
Grid.ColumnSpan="2"
AlternatingRowBackground="#FFF2F2F2"
AreRowDetailsFrozen="True"
CanUserResizeRows="False"
ClipboardCopyMode="IncludeHeader"
Focusable="False"
MinRowHeight="1">
</DataGrid>
Upvotes: 0
Views: 437
Reputation: 772
After binding data to the data grid, you can check the record count and display a message in case the record count is 0. Hope the example in this page helps.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.aspx
Upvotes: 1