swapnil jatkar

swapnil jatkar

  • NA
  • 11
  • 15.3k

Data grid problem in windows application using c#

Feb 25 2012 6:04 AM
hi,

I am working on a windows applications using c#. I have a form(parent form) with data grid that displays a records from database. I have a update button near the data grid. When a user selects a record from grid & clicks update button a new form (child form) opens that consists of a form for updating the selected record. The child form consist of a update button that updates the entry in the same database table which is bind to that datagrid. when a user clicks the update button on the child form, all the data gets updated in the database & the child form gets closed. Now the focus comes on parent form, but the datagrid don't show the changes happened in the database,even though it is bind after update the database.

I have also tried to null the datasource before binding after updation.

Need some urgent help..

Thanks in Advance.







 private void butBilling_update_Click(object sender, EventArgs e)
  {
 
  try
  {
  if (DGV_outward.SelectedRows.Count > 0)
  {
  String bill_no = DGV_outward.SelectedRows[0].Cells[0].Value.ToString();
  update_bill b = new update_bill(bill_no);        <--------------- Update is name of child form,,on which update form is designed
  b.Show();
  this.Refresh();

  OleDbConnection con = new OleDbConnection(ConnectionString);
  con.Open();
  cmd = new OleDbCommand("select * from dbo_Outward_Billing order by Outward_bill_ID desc", con);
  dr = cmd.ExecuteReader();
  DataTable dt = new DataTable();
  dt.Load(dr);
  DGV_outward.DataSource = dt;
  con.Close();
 

  }
  else
  {
  MessageBox.Show("Select a record");
  }
 
  }
  catch (Exception ex )
  {
  MessageBox.Show("please select a record for update..");
  }
  }




Answers (3)