Hi,

I'm trying to send row values of a grid as parameter of direct method. All components (store, grid and button) in page are created dynamically.

here is the code for creating the components:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Controls.Clear();
                Object dt = (Object)Session["dt"];

                if (dt is DataSet)
                {
                    foreach (DataTable t in ((DataSet)dt).Tables)
                    {
                        LoadTableData(t);
                    }
                }

                if (dt is DataTable)
                {
                    LoadTableData((DataTable)dt);
                }
            }
        }

private void LoadTableData(DataTable dt)
        {

            Store store = new Store { ID = "Store"+dt.TableName, IDMode = IDMode.Explicit };            
            store.Reader.Add(new JsonReader());
            store.DirectEventConfig.IsUpload = true;
            store.AutoLoadParams.Add(new Parameter("start", "0", ParameterMode.Raw));
            store.AutoLoadParams.Add(new Parameter("limit", "15", ParameterMode.Raw));
            store.SubmitData += Store1_Submit;
            this.Controls.Add(store);

            GridPanel grid = new GridPanel
            {
                ID = "GridPanel"+dt.TableName,
                AutoScroll = true,
                AutoHeight = true,
                StripeRows = true,               
                AutoWidth = true,
                Icon=Icon.Table,
                IDMode = IDMode.Explicit                
            };

            grid.Store.Add(store);
            grid.Title = dt.TableName;
            grid.TitleCollapse = true;
            grid.LoadMask.ShowMask = true;
            grid.LoadMask.Msg = "Loading...";                
            PagingToolbar pager = new Ext.Net.PagingToolbar { PageSize = 15 };
            pager.Width = 800;
            pager.StoreID = store.ID;
            grid.BottomBar.Add(pager);
            Toolbar topbar = new Toolbar();
            Ext.Net.Button btn_ToExcel = new Button();
            btn_ToExcel.ID = "btn_ToExcel";
            btn_ToExcel.IDMode = IDMode.Explicit;
            btn_ToExcel.Text = "To Excel";
            btn_ToExcel.Icon = Ext.Net.Icon.PageExcel;
           
//This the problematic part
            btn_ToExcel.OnClientClick = "Ext.net.DirectMethods.Test(\"" + "Ext.encode(" + grid.ClientID + ".getRowsValues({selectedOnly : false}))\");";
           
            topbar.Items.Add(btn_ToExcel);
            grid.TopBar.Add(topbar);
            
            int _n = 0;

            foreach (DataColumn column in dt.Columns)
            {
                if (column.ColumnName == "ID")
                {
                    ((JsonReader)store.Reader[0]).IDProperty = "ID";
                }

                store.Reader[0].Fields.Add(new RecordField(column.ColumnName));
                if (column.ColumnName != "ID")
                {
                    Column _col = new Column
                    {
                        ColumnID = ("CLM_" + _n.ToString()),
                        Header = column.Caption,
                        Tooltip = column.Caption,
                        DataIndex = column.ColumnName
                    };
                    grid.ColumnModel.Columns.Add(_col);
                }
                _n++;
            }

            grid.View.Add(new GridView() { ForceFit = true });           
            this.Controls.Add(grid);

            store.DataSource = dt;
            store.DataBind();            
        }

[DirectMethod]
 public void Test(string t)
        {
            string r = t;
//here i need to do export to excel
        }
And here is .aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    
    <form id="form1" runat="server">
        <ext:ResourceManager ID="rmDefault" Locale="Client"  runat="server" />
    </form>
</body>
</html>