EmptyDataTemplate and EmptyDataText do not work in GridView

It seems I can not use EmptyDataTemplateor EmptyDataTextfor GridView.

I extract the contents GridViewin the code and attach them with DataBind(). I tried to use them as nulland as empty List, and in both cases the text that I put in EmptyDataTemplateor EmptyDataTextdoes not appear.

What am I doing wrong?

EDIT (code snippet)

This is my gridview:

<asp:GridView ID="grid" runat="server" EmptyDataText="EMPTY">
</asp:GridView>

And I tried these two for data binding:

grid.DataSource = new List<object>();
grid.DataBind();

grid.DataSource = null;
grid.DataBind();
+4
source share
5 answers

CSS-Friendly Control Adapters. ( ), EmptyDataTemplate EmptyDataText , .

, App_Browsers CSSFriendlyAdapters.browser ( , ):

<adapter controlType="System.Web.UI.WebControls.GridView"
               adapterType="CSSFriendly.GridViewAdapter" />

, .

+5

, DataBind, , .

+4

EmptyDataTemplate EmptyDataText, , - , EmptyDataText.

GridView, EmptyDataText, EmptyDataTemplate, ,

<%-- GridTest.ascx --%>
<asp:GridView ID="Grid" runat="server" EmptyDataText="No Data!" />

// GridTest.ascx.cs
Grid.DataSource = new List<object>();
Grid.DataBind();

- , ?

+2

.....

    <Columns>
             ............
             ............
             ............
    <Columns>
<EmptyDataTemplate>
        <asp:Label ID="lblEmptyTxt" runat="server" Text="No Data"></asp:Label>
      </EmptyDataTemplate>
                        </asp:GridView>
+1

, . GridView ForeColor , , BackColor!

0

All Articles