The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

GridPanel not showing when method called in button directclick but show when method called in page_load event

  1. #1

    GridPanel not showing when method called in button directclick but show when method called in page_load event

    hello, I have this weird issue.
    I have a method which I call from button directclick event and also page_load event.
    when I call it from button directclick event, the data were not shown in a GridPanel.
    But when I call it from page_load event, the data were shown perfectly in a GridPanel.

    here is the sample code

    <html xmlns="">
    <head runat="server">
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" ID="rms1" />
                    <ext:Store ID="Store1" runat="server" PageSize="10" />
                    <ext:RowSelectionModel runat="server" Mode="Multi" />
                    <ext:GridView runat="server" StripeRows="true" />
                    <ext:PagingToolbar runat="server">
                            <ext:ProgressBarPager runat="server" />
            <ext:Button ID="btn1" runat="server" OnDirectClick="btn1_DirectClick" Text="load xls data" />
    =====Behind Code=====
    protected void Page_Load(object sender, EventArgs e)
                //if (!IsPostBack)
                //    this.BindDataFromXLS();
                //if (!X.IsAjaxRequest)
                //    this.BindDataFromXLS();
            private void BindDataFromXLS()
                XSSFWorkbook hssfwb;
                using (FileStream file = new FileStream(@"D:\lokih\sample2.xlsx", FileMode.Open, FileAccess.Read))
                    hssfwb = new XSSFWorkbook(file);
                ISheet sheet = hssfwb.GetSheetAt(1);
                DataTable dataTest = new DataTable(sheet.SheetName);
                IRow headerRow = sheet.GetRow(0);
                Model m = new Model();
                foreach (ICell headerCell in headerRow)
                    GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = Convert.ToString(headerCell), Text = Convert.ToString(headerCell) });
                int rowIndex = 0, rowPosition = 0;
                foreach (IRow rowItem in sheet)
                    if (rowIndex++ == 0) continue;
                    DataRow dataRow = dataTest.NewRow();
                    dataRow.ItemArray = rowItem.Cells.Select(c => Convert.ToString(c)).ToArray();
                Store1 = this.GridPanel1.GetStore();
                Store1.DataSource = dataTest;
            protected void btn1_DirectClick(object sender, DirectEventArgs e)
    Hope there are some good explanations for these :D

    Thank you

    Attachment 24925
    Attachment 24930
    Attachment 24931
    Attachment 24932
    Attachment 24933
    Last edited by lokihnahta; May 03, 2017 at 4:07 AM.

Similar Threads

  1. Codebehind event called from Task
    By aluna in forum 1.x Help
    Replies: 1
    Last Post: May 12, 2016, 6:34 PM
  2. Issue with Direct method called via Javascript
    By simonespagna in forum 2.x Help
    Replies: 1
    Last Post: Feb 22, 2015, 12:29 AM
  3. Replies: 3
    Last Post: Sep 26, 2014, 7:32 PM
  4. Replies: 2
    Last Post: Aug 30, 2012, 9:37 PM
  5. Replies: 2
    Last Post: Dec 08, 2011, 1:00 PM

Tags for this Thread

Posting Permissions