private void button1_Click(object sender, EventArgs e)
{
ProductDbEntities productDb = new ProductDbEntities();
pdmodel.Id = int.Parse(textBox1.Text);
pdmodel.Name = textBox2.Text;
pdmodel.price = Decimal.Parse(textBox3.Text);
productDb.Products.Add(pdmodel);
productDb.SaveChanges();
MessageBox.Show("data inserted success");
populateDataGridView();
}
private void populateDataGridView()
{
ProductDbEntities db = new ProductDbEntities();
dataGridView1.DataSource = db.Products.ToList<Product>();
}
private void Form1_Load(object sender, EventArgs e)
{
populateDataGridView();
}
No comments:
Post a Comment