Home DotNet Radgrid Empty Template For Empty Datasource
07.09.2010
Main Menu
Programming
.NET Controls
Operating System
Databases
Articles
Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Yahoo Add to: Technorati Add to: Google
Radgrid Empty Template For Empty Datasource

Whenever using a Radgrid control there is always a possibility that the datasource return an empty record dataset. When the datasource is null or empty a user need to be informed with a message indicating as such. To show such messages you need to enable the NoRecordsTemplate property of the Radgrid. When the NoRecordsTemplate is set to true it will show the empty template if there are no data return from the datasource. Also if you would like to display the header when there are no data in the datasource you can set the property ShowHeadersWhenNoRecords to true.

EXAMPLES:

<telerik:RadGrid ID="gridEntries" Width="1100px" runat="server" AutoGenerateColumns="false"

        Skin="Sunset" AllowMultiRowSelection="false" OnNeedDataSource="gridEntries_NeedDataSource"

        OnDeleteCommand="gridEntries_DeleteCommand" OnItemCommand="gridEntries_ItemCommand">

        <ClientSettings>

        </ClientSettings>

 

        <MasterTableView HierarchyDefaultExpanded="false" EditMode="PopUp" HierarchyLoadMode="Client"

            ShowHeadersWhenNoRecords="false" EnableNoRecordsTemplate="true" DataKeyNames="EntryID" CommandItemDisplay="None">

            <NoRecordsTemplate>

                <div>There are no records to display</div>

            </NoRecordsTemplate>

            <Columns>

                <telerik:GridBoundColumn DataField="SignInDateTime" DataFormatString="{0:dd/MM/yyyy}"

                    ItemStyle-Width="60" HeaderText="Date">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="SignInDateTime" DataFormatString="{0:HH:mm}"

                    ItemStyle-Width="30" HeaderText="Time">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="Name" ItemStyle-Width="150" HeaderText="Name">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="ContactDetails" ItemStyle-Width="100" HeaderText="Contact Details">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="NumberOfIndividuals" ItemStyle-Width="100" HeaderText="No of Individuals">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="reasonForVisit" ItemStyle-Width="400" HeaderText="Reason For Visit">

                </telerik:GridBoundColumn>

                <telerik:GridButtonColumn CommandName="Delete" Text="Sign Out" UniqueName="DeleteColumn"

                    ButtonType="PushButton" ItemStyle-Width="50">

                </telerik:GridButtonColumn>

            </Columns>

        </MasterTableView>

        <HeaderStyle Font-Bold="true" HorizontalAlign="Center" />

        <ItemStyle HorizontalAlign="Left" />

        <AlternatingItemStyle HorizontalAlign="Left" /> 

    </telerik:RadGrid>



Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."