GridPanel is not displaying " No Records Found" On Click of Button(ASP.NET) in full post back

  1. #1

    GridPanel is not displaying " No Records Found" On Click of Button(ASP.NET) in full post back

    HI

    When i clicked on ASP.net button in asp dotnet page, if there are no records in datatable then grid is not displaying "no records found" message
    ==================================================
    E.g :
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    public int CurrentYear = Convert.ToInt16(DateTime.Now.AddMonths(-1).Year);
    
    private object[] strEmployee
    {
    get
    {
    return new object[]
    {
    new object[] { "1", "Test 1" },
    new object[] { "2", "Test 2" },
    new object[] { "3", "Test 3" }
    };
    }
    }
    
    protected void btnWithRecords_Click(object sender, EventArgs e)
    {
    this.Store1.DataSource = strEmployee;
    this.Store1.DataBind();
    }
    
    protected void btnWithOutRecords_Click(object sender, EventArgs e)
    {
    this.Store1.RemoveAll();
    }
    
    protected void btnExtEvent_click(object sender, DirectEventArgs e)
    {
    this.Store1.RemoveAll();
    }
    
    
    
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server" style="padding: 30px">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Width="250">
    <Store>
    <ext:Store ID="Store1" runat="server">
    <Reader>
    <ext:ArrayReader>
    <Fields>
    <ext:RecordField Name="EmployeeId" />
    <ext:RecordField Name="Name" />
    </Fields>
    </ext:ArrayReader>
    </Reader>
    </ext:Store>
    </Store>
    <ColumnModel ID="ColumnModel1" runat="server">
    <Columns>
    <ext:Column Header="EmployeeId" DataIndex="EmployeeId" />
    <ext:Column Header="Name" DataIndex="Name" />
    </Columns>
    </ColumnModel>
    <View>
    <ext:GridView ID="grdView" runat="server" EmptyText="No Records" />
    </View>
    </ext:GridPanel>
    <asp:Button ID="btnWithRecords" runat="server" OnClick="btnWithRecords_Click" Text="With Records" />
    <asp:Button ID="btnWithOutRecords" runat="server" OnClick="btnWithOutRecords_Click"
    Text="With Out Records" />
    
    <ext:Button ID="btnExtEvent" runat="server" Text="With Ext Event" >
    <DirectEvents>
    <Click OnEvent="btnExtEvent_click" />
    </DirectEvents>
    </ext:Button>
    </form>
    </body>
    </html>

    Regards
    Praveen Nampally
    Last edited by Daniil; Jan 08, 2012 at 5:06 AM. Reason: Please use [CODE] tags
  2. #2
    Can you provide some sample code to reproduce the problem
  3. #3

    Example to above post

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        public int CurrentYear = Convert.ToInt16(DateTime.Now.AddMonths(-1).Year);
    
        private object[] strEmployee
        {
            get
            {
                return new object[]
                {
                    new object[] { "1", "Test 1" },
                    new object[] { "2", "Test 2" },
                    new object[] { "3", "Test 3" }
                };
            }
        }
    
        protected void btnWithRecords_Click(object sender, EventArgs e)
        {
            this.Store1.DataSource = strEmployee;
            this.Store1.DataBind();
        }
    
        protected void btnWithOutRecords_Click(object sender, EventArgs e)
        {
            this.Store1.RemoveAll();
        }
        
        protected void btnExtEvent_click(object sender, DirectEventArgs e)
        {
            this.Store1.RemoveAll();
        }
        
        
        
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server" style="padding: 30px">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Width="250">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="EmployeeId" />
                                <ext:RecordField Name="Name" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column Header="EmployeeId" DataIndex="EmployeeId" />
                    <ext:Column Header="Name" DataIndex="Name" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView ID="grdView" runat="server" EmptyText="No Records" />
            </View>
        </ext:GridPanel>
        <asp:Button ID="btnWithRecords" runat="server" OnClick="btnWithRecords_Click" Text="With Records" />
        <asp:Button ID="btnWithOutRecords" runat="server" OnClick="btnWithOutRecords_Click"
            Text="With Out Records" />
            
            <ext:Button ID="btnExtEvent" runat="server" Text="With Ext Event" >
            <DirectEvents>
                <Click OnEvent="btnExtEvent_click" />
            </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 06, 2012 at 11:28 AM. Reason: Please use [CODE] tags
  4. #4
    Hi,

    Yes, providing a sample to reproduce would be best, because I was unable to reproduce the problem using the example below.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void DataBind(object sender, EventArgs e)
        {
            this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test1", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" }
                };
            this.Store1.DataBind();   
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel runat="server" AutoHeight="true">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                    <ext:RecordField Name="test3" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1" />
                        <ext:Column Header="Test2" DataIndex="test2" />
                        <ext:Column Header="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
            <asp:Button runat="server" Text="DataBind" OnClick="DataBind" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 08, 2012 at 5:07 AM.
  5. #5
    Thanks for the sample.

    I'm not sure why you are expecting a grid to be data bound on the "btnWithOutRecords" button click.

    Two handlers with
    this.Store1.RemoveAll();
    are executed when this button is clicked.
  6. #6

    In Ext button Event grid show " No Records" , but in aspnet button it does not show "No Records"... Can you Please provide sol

    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void DataBind(object sender, EventArgs e)
        {
            this.Store1.RemoveAll();
        }
    
        protected void Button2_CLICK(object SENDER, DirectEventArgs E)
        {
            this.Store1.RemoveAll();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form id="Form1" runat="server" style="padding:20px">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Width="250">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                    <ext:Column Header="Test3" DataIndex="test3" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView ID="GridView1" runat="server" EmptyText="No Records" />
            </View>
        </ext:GridPanel>
        <asp:Button ID="Button1" runat="server" Text="Asp Dot Net Event" OnClick="DataBind" />
      
        <ext:Button ID="Button2" runat="server" Text="Ext Event">
            <DirectEvents>
                <Click OnEvent="Button2_CLICK" />
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 08, 2012 at 4:53 AM. Reason: Please use [CODE] tags
  7. #7
    You should not bind a Store with a data or bind it again with an empty data during a common ASP.NET event.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test1", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" },
                };
                this.Store1.DataBind();
            }
        }
    
        protected void ApsNetClick(object sender, EventArgs e)
        {
            this.Store1.DataSource = new object[] { };
            this.Store1.DataBind();
        }
    
        protected void DirectEventClick(object sender, DirectEventArgs e)
        {
            this.Store1.RemoveAll();
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel runat="server" AutoHeight="true" Width="250">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                    <ext:RecordField Name="test3" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1" />
                        <ext:Column Header="Test2" DataIndex="test2" />
                        <ext:Column Header="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView 
                        runat="server" 
                        EmptyText="No Records" 
                        DeferEmptyText="false" />
                </View>
            </ext:GridPanel>
            <asp:Button runat="server" Text="Asp Dot Net Event" OnClick="ApsNetClick" />
       
            <ext:Button runat="server" Text="Ext Event" OnDirectClick="DirectEventClick" />
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 1
    Last Post: Aug 12, 2012, 8:32 AM
  2. Replies: 5
    Last Post: May 02, 2012, 6:37 PM
  3. Replies: 4
    Last Post: Oct 11, 2011, 3:42 AM
  4. Replies: 12
    Last Post: Apr 13, 2011, 4:28 PM
  5. Replies: 3
    Last Post: Aug 09, 2010, 4:01 PM

Tags for this Thread

Posting Permissions