1
Reply

how can I add a new row to datagrid at every button click

Yucel Emir

Yucel Emir

May 12 2016 8:57 AM
309

I want to add new row to gridcontrol at every button click. I tried many ways but no success. I am sending my code below. 

private void B_Click(object sender, EventArgs e)
{
Button bt = (Button)sender;
 int productId = (int)bt.Tag; AddProductDataContext db = new AddProductDataContext(); 
decimal Quantity; 
decimal.TryParse(txtCalculator.Text, out Quantity);           
gridControl1.DataSource = from inv in db.Inventories where inv.RecId == productId       
                            select new {                                        
inventoryName = inv.InventoryName, 
Quantity, Total = Quantity * inv.InventoryPrice };          
gridView1.AddNewRow();         
gridView1.UpdateCurrentRow();

}

Is there anyone to help me out there for the above? Thanks in advance for your precious replies.

Answers (1)