private void AddRowButton_Click(object sender, EventArgs e) { // Create a new instance of a Customers row. northwindDataSet1.CustomersRow NewRow = (northwindDataSet1.CustomersRow)northwindDataSet1.Customers.NewRow(); // Set the values for each column in the row. NewRow.CustomerID = "WINGT"; NewRow.CompanyName = "Wingtip Toys"; NewRow.ContactName = "Steve Lasker"; NewRow.ContactTitle = "CEO"; NewRow.Address = "1234 Main Street"; NewRow.City = "Buffalo"; NewRow.Region = "NY"; NewRow.PostalCode = "98052"; NewRow.Country = "USA"; NewRow.Phone = "206-555-0111"; NewRow.Fax = "206-555-0112"; // Add the new row to the Rows collection of the Customers table. try { northwindDataSet1.Customers.Rows.Add(NewRow); } catch (Exception ex) { MessageBox.Show(ex.Message, "Add Row Failed"); } }
private northwindDataSet1.CustomersRow GetSelectedRow() { // Get the selected DataRow String SelectedCustomerID = CustomersDataGridView.CurrentRow.Cells["CustomerID"].Value.ToString(); // Using the SelectedCustomerID get the selected row. northwindDataSet1.CustomersRow SelectedRow = northwindDataSet1.Customers.FindByCustomerID(SelectedCustomerID); return(SelectedRow); }