Programmatically create Grid

Hi,

is there a sample available how to create grid programmatically using C#?

Thank you in advance,
Andre

2 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 18, 2020 03:30 PM UTC

Hi Andre, 

Thanks for contacting Syncfusion Support. 

Query#:- is there a sample available how to create grid programmatically using C#? 
 
As per your requirement we have rendered the Grid programmatically at server end on dropdown change. Based on the selected value of the dropdown we have rendered Grid and button in dynamic way using c#. 
Refer to the code example:- 

<asp:PlaceHolder ID="MainContent" runat="server"></asp:PlaceHolder> 
 
C#:- 

    private void AddGridToThisPanel(string srcName, Panel p) 
        { 
            if (srcName == "Source1") 
            { 
                Syncfusion.JavaScript.Web.Grid x = new global::Syncfusion.JavaScript.Web.Grid(); 
                x.Columns.Clear(); 
                x.EnableViewState = false; 
                 BindDataSource(); 
                x.DataSource = order.ToList(); 
                x.DataBind(); 
                x.AllowPaging = true; 
                x.PageSettings.PageSize = 5; 
 
                p.Controls.Add(x); 
            } 
 
            else 
            { 
                Syncfusion.JavaScript.Web.Button y = new global::Syncfusion.JavaScript.Web.Button(); 
                y.Text = "Render Button"; 
                p.Controls.Add(y); 
            } 
        } 
 
         

 
  
 
Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 18, 2020 03:33 PM UTC

Hi Andre, 

Thanks for contacting Syncfusion Support. 

Query#:- is there a sample available how to create grid programmatically using C#? 
 
As per your requirement we have rendered the Grid programmatically at server end on dropdown change. Based on the selected value of the dropdown we have rendered Grid and button in dynamic way using c#. 
Refer to the code example:- 

<asp:PlaceHolder ID="MainContent" runat="server"></asp:PlaceHolder> 
 
C#:- 

    private void AddGridToThisPanel(string srcName, Panel p) 
        { 
            if (srcName == "Source1") 
            { 
                Syncfusion.JavaScript.Web.Grid x = new global::Syncfusion.JavaScript.Web.Grid(); 
                x.Columns.Clear(); 
                x.EnableViewState = false; 
                 BindDataSource(); 
                x.DataSource = order.ToList(); 
                x.DataBind(); 
                x.AllowPaging = true; 
                x.PageSettings.PageSize = 5; 
 
                p.Controls.Add(x); 
            } 
 
            else 
            { 
                Syncfusion.JavaScript.Web.Button y = new global::Syncfusion.JavaScript.Web.Button(); 
                y.Text = "Render Button"; 
                p.Controls.Add(y); 
            } 
        } 
 
         

 
  
 
Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon