add rows dynamically

How can I add rows to the sfdatagrid dynamically?

1 Reply

AA Arulraj A Syncfusion Team September 3, 2018 07:25 AM UTC

Hi Diego, 

Thanks for contacting Syncfusion support.  

You can dynamically add rows to the SfDataGrid by adding the records to the underlying collection. Please refer to the below code example and sample form the given location. 
Code Example : 
OrderInfoCollection data; 
public Form1() 
{ 
    InitializeComponent(); 
    data = new OrderInfoCollection(); 
    sfDataGrid.DataSource = data.OrdersListDetails; 
} 
 
 
private void button1_Click(object sender, System.EventArgs e) 
{ 
    data.OrdersListDetails.Add(new OrderInfo() { OrderID = 1001, CustomerID = "FRANS", ProductName = "Alice Mutton" }); 
} 


You can also make use of the AddNewRow support in SfDataGrid to add new records to the underlying collection. Please refer to the following UG link for AddNewRow. 

Arulraj A 


Loader.
Up arrow icon