This is a migrated thread and some comments may be shown as answers.

[Solved] No records should be displayed in grid

4 Answers 329 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saran kumar
Top achievements
Rank 1
Saran kumar asked on 24 Dec 2009, 07:36 AM
<telerik:RadGrid ID="gvLeadsHistory" runat="server" CssClass="radgrid" AllowPaging="True" 
                                EnableEmbeddedSkins="false" ShowFooter="false" AutoGenerateColumns="False" GridLines="None" 
                                AllowSorting="True" Width="450px" AllowMultiRowSelection="true" OnItemDataBound="gvLeadsHistory_ItemDataBound" 
                                OnSortCommand="gvLeadsHistory_SortCommand">  
                                <MasterTableView CssClass="radgridMasterTable" AllowCustomSorting="true" Width="100%" 
                                    ShowHeadersWhenNoRecords="true" TableLayout="Fixed" ClientDataKeyNames="lead_id">  
                                    <NoRecordsTemplate> 
                                        <div style="padding: 5px 0px 5px 0px; text-align: center; height: 20px; font-family: Verdana, Arial, Helvetica, sans-serif;  
                                            font-size: 1.1em; font-weight: bold;"> 
                                            No Lead History Records.</div> 
                                    </NoRecordsTemplate> 
                                    <HeaderStyle CssClass="radgridheader" VerticalAlign="Middle" /> 
                                    <Columns> 
                                        <telerik:GridBoundColumn UniqueName="Date" HeaderText="Date" AllowSorting="true" 
                                            DataField="Activity_Date" HeaderStyle-Width="70" SortExpression="Activity_Date" 
                                            ShowSortIcon="true" SortAscImageUrl="../Images/icons/arrow_down.gif" SortDescImageUrl="../Images/icons/arrow_up.gif">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn UniqueName="Type" HeaderText="Type" DataField="Activity_Type" 
                                            HeaderStyle-Width="90" SortExpression="Activity_Type" ShowSortIcon="true" SortAscImageUrl="../Images/icons/arrow_down.gif" 
                                            SortDescImageUrl="../Images/icons/arrow_up.gif">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn UniqueName="Description" HeaderText="Description" DataField="Activity_Description" 
                                            HeaderStyle-Width="200" AllowSorting="false">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridTemplateColumn HeaderStyle-VerticalAlign="Middle" UniqueName="TypeOfLead" 
                                            HeaderText="Action" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="40">  
                                            <ItemTemplate> 
                                                <asp:LinkButton ID="imgbActivityEdit" runat="server" ImageUrl="../Images/icons/icon_edit.gif" 
                                                    ToolTip="Edit" OnCommand="gvActivity_RowEditing" CommandArgument='<%# Eval("[Activity_Id]") %>'>  
                                                    <img src="../Images/icons/icon_edit.gif" alt="Edit"/></asp:LinkButton> 
                                                <asp:LinkButton ID="imgbActivityDelete" runat="server" ImageUrl="../Images/icons/icon_delete.gif" 
                                                    ToolTip="Delete" OnCommand="ActivityDelete_Click" CommandArgument='<%# Eval("[Activity_Id]") %>'>  
                                                    <img src="../Images/icons/icon_delete.gif" alt="Delete"/></asp:LinkButton> 
                                                <asp:Label ID="lblActivityId" runat="server" Text='<%# Eval("[Activity_Id]") %>' 
                                                    Visible="False"></asp:Label> 
                                                <asp:Label ID="lblActivityType" runat="server" Text='<%# Eval("[Activity_Type]") %>' 
                                                    Visible="False"></asp:Label> 
                                            </ItemTemplate> 
                                        </telerik:GridTemplateColumn> 
                                    </Columns> 
                                </MasterTableView> 
                            </telerik:RadGrid> 
hi please find attached the model of my rad grid, here im having Norecorf template, but since im having grid item template, that two images are still displaying, if the record set have no records, instead of showing "No records"
please help.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Dec 2009, 12:55 PM
Hello Saran,

Please note that NoRecordsTemplate will be shown, when there are no items in RadGrid - I examined the screenshot and noticed that you have one empty item.

For your convenience I created a sample project, based on your code. Test it on your end and let me know whether it works as expected.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saran kumar
Top achievements
Rank 1
answered on 29 Dec 2009, 10:00 AM
hi as you suggest it returns "empty" record so that the no records template is not activated.

the code u given
protected void Page_Load(object sender, EventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add(new DataColumn("Test"));
        gvLeadsHistory.DataSource = table;
    }

adds a cloumn, which will not show the no records template, i belive.

i want to show No records temp, when i have empty record returned from dB.

please help.
0
Daniel
Telerik team
answered on 04 Jan 2010, 02:47 PM
Hello Saran,

"the code u given...adds a cloumn, which will not show the no records template, i belive."

Did you try my sample project?

i want to show No records temp, when i have empty record returned from dB.
I'm afraid this functionality is not supported by RadGrid. It works only when you don't have any items in the data source.

Let me know if you need more information.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saran kumar
Top achievements
Rank 1
answered on 06 Jan 2010, 08:02 AM
hi,

we tried deleting records if it return "empty" records in the data set.

the code is
DataRow[] rows = dt.Select("Lead_id = 'empty'");  
                if (rows.Length > 0)  
                {  
                    foreach (DataRow row in rows)  
                    {  
                        row.Delete();  
                    }  
                    dt.AcceptChanges();  
                } 

with this the record set become 0 after deleting, and by default it shows No records template.

thanks for your timely help and responce.

nice forum

saran
Tags
Grid
Asked by
Saran kumar
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Saran kumar
Top achievements
Rank 1
Share this question
or