Telerik Radgrid not showing in browser

Telerik Rad control simply displays as a solid straight line in the browser. But in the design of Visual Studio, it displays correctly.

<telerik:RadGrid ID="RadGrid1" runat="server" onneeddatasource="RadGrid1_NeedDataSource"> <MasterTableView ShowHeadersWhenNoRecords="false" AutoGenerateColumns="true"> <NoRecordsTemplate> <div>There are no records to display</div> </NoRecordsTemplate> </MasterTableView> </telerik:RadGrid> 

Can someone please help me on this

+4
source share
2 answers

If the RadGrid1 data source is Nothing / Null, the control is not actually connected, even if databind () is called. An empty collection can be bound to a control to display a NoRecordsTemplate.

At VB.net:
RadGrid1.DataSource = new Object() {}

In C #:

 RadGrid1.DataSource = new object[] { }; 
+6
source

First you need to configure a few parameters so as not to display the data pattern, first you need an actual data source that returns null or empty, if you just do this to check the target and want to avoid the actual data source, then the code provided by ItsPete is good. You also need to place EnableNoRecordsTemplate = "true" in the MasterTableView tags.

Take a look at this code.

  <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" DataSourceID="SqlDataSource1"> <MasterTableView EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="false" AutoGenerateColumns="False" datakeynames="ID" datasourceid="SqlDataSource1"> <NoRecordsTemplate> No Data Found. </NoRecordsTemplate> <Columns> <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" DefaultInsertValue="" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="NAME" DefaultInsertValue="" HeaderText="NAME" SortExpression="NAME" UniqueName="NAME"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PASSWORD" DefaultInsertValue="" HeaderText="PASSWORD" SortExpression="PASSWORD" UniqueName="PASSWORD"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DEPARTMENT" DefaultInsertValue="" HeaderText="DEPARTMENT" SortExpression="DEPARTMENT" UniqueName="DEPARTMENT"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>" SelectCommand="SELECT * from Users WHERE ID = '0'"> </asp:SqlDataSource> 

The data columns are irrelevant here (just an example). For more information about RadGrid, visit the RadGrid Tips - Empty Data Post .

0
source

Source: https://habr.com/ru/post/1343656/


All Articles