I have a webgrid which displays the headers and group by box even if there is no data to display. How do I display a message 'Your search criteria have given no results.Please re-try with a different search criteria' when there is no data to display?
As indicated elsewhere, the NoDataMessage only appears if not only no Rows but also no Columns exist. So if you can detect no Rows and then force no Columns, it works fine.
To do that, use the ultrawebgrid's PreRender event. There, just add one line of code:
If MyGrid.Rows.Count = 0 then MyGrid.Columns.Clear()
I've found an example that works. Here's my markup:
<igtbl:UltraWebGrid ID="dgSuppFiles" runat="server" Width="736px" Height="83px">
<DisplayLayout AllowDeleteDefault="Yes" AllowAddNewDefault="Yes" RowHeightDefault="20px" Version="3.00" SelectTypeRowDefault="Single" BorderCollapseDefault="Separate" Name="dgSuppFiles" AllowUpdateDefault="Yes" NoDataMessage="No documents have been uploaded.">
<AddNewBox> <BoxStyle borderwidth="1px" borderstyle="Solid" backcolor="LightGray" /> </AddNewBox>
<Pager> <PagerStyle BorderWidth="1px" BorderStyle="solid" BackColor="LightGray" /> </Pager>
<HeaderStyleDefault Font-Names="Verdana" Font-Bold="True" BorderStyle="Solid" HorizontalAlign="Left" BackColor="#EBF0F9"> <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails> </HeaderStyleDefault>
<FrameStyle Width="736px" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderColor="#517DBF" BorderStyle="Solid" BackColor="Transparent" Height="83px"> </FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray"> <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails> </FooterStyleDefault>
<ClientSideEvents AfterRowDeletedHandler="UltraWebGrid1_AfterRowDeletedHandler" />
<ActivationObject BorderColor="1, 68, 208"></ActivationObject>
<EditCellStyleDefault BorderWidth="0px" BorderStyle="None"></EditCellStyleDefault>
<SelectedRowStyleDefault BackColor="#9FBEEB"></SelectedRowStyleDefault>
<RowAlternateStyleDefault BackColor="White"></RowAlternateStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="#517DBF" BorderStyle="Solid"> <Padding Left="3px"></Padding> <BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails> </RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand HeaderClickAction="SortMulti" AllowUpdate="No" AllowAdd="No" CellClickAction="Edit"> <HeaderStyle BackColor="#EAF2F7"></HeaderStyle> </igtbl:UltraGridBand>
</Bands>
</igtbl:UltraWebGrid>
GokulKannanK said:I have tried using the NoDataMessage without any effect.
IIRC, I've seen it work. Then again, I'm unable to find an example in my own applications; for some reason I ended up not relying on it.
Sorry. I'm just a developer like you. Maybe the IG staff will give us a clue.
Thanks. I added the visiblity code in Selected handler and it works.
I was just wondering why the EmptyDataTemplate has not been not provided.
In the SqlDataSource's .Selected hanler, you might try hiding the grid and showing your "try again" message.
Not elegant, but it'll work.