On your first form, a button handler to get the data from the text box & open the second form
private void buttonHandler_Activate(object sender, System.EventArgs e)
{
int customerId = Convert.ToInt32(this.personTextBox.Text);
using (GridForm grid = new GridForm ())
{
grid.GetCustomerDetails(customerId);
grid.ShowDialog(this);
}
}
On your second form (GridForm), a public method that takes the customer id and populates the screen.
public void GetCustomerDetails(int customerId)
{
string cString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer";
SqlConnection myConnection = new SqlConnection(cString);
SqlDataAdapter myAdapter = new SqlDataAdapter();
myConnection.Open();
SqlCommand myCommand = new SqlCommand("SELECT * FROM MyTable WHERE CustomerId = " + customerId.ToString(),
myConnection);
myCommand.CommandType = CommandType.Text;
myAdapter.SelectCommand = myCommand;
ds = new DataSet("Customers");
myAdapter.Fill(ds);
this.myGridReference.DataSource = ds;
this.myGridReference.DataBind();
}
Disclaimer - Dodgy data access that I don't endorse at all! But you get the idea
* On you 1st form, validate data entry, create instance of second form, pass collected data to second form
* 2nd form has method to receive entry and populate itself