From: Maddy on
I am a newbie making a database app. My database is a MS Access
database. I have a startup form with a datagrid showing all the
records in table called Report.(The Datagrid automatically created a
dataset of the entire database.) When a report is selected on this
form, I want another form to open which has data aware text boxes
connected a Details table.(I have no problems creating the forms) Both
these tables have a RecordID and I want this form to display only the
records which have the same RecordID as row which was selected in the
datagrid.
Can someone please help me out on this?

Thanks,
Regards,
Nitin
From: Rich P on
Here is one thing you could try: I use a datagridview control on my
form which the datasource is based on a dataTable contained in a Dataset
object. I call the dataset ds1 and the dataTable is ds1.Tables["tbl1"]
which I populate from a OleDBDataAdapter.

private void dgrv2_CellClick(object sender, DataGridViewCellEventArgs e)
{
string str1 =
((DataGridView)sender).Rows[e.RowIndex].Cells[0].Value.ToString();

DataRow drF[] = ds1.Tables["tbl1"].Select("rowID = " + str1);

Form2 frm = new Form2(drF);
frm.Show();


}

Now the constructor of Form2 -- which contains your textboxes -- will
receive a DataRow[] object. To get the row information do this:

txt0.Text = drF[0][0].ToString();
txt1.Text = drF[0][1].ToString();
...
txt4.Text = drF[0][3].ToString();

and now you have populated your textboxes based on the selected row from
the datagridview control contained in Form1.

You could also use a Linq Query against the DataTable which would give
you more versatility, but this is simpler for now for basic usage.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
From: Maddy on
Thanks for the solution. I will try it out and get back if I have any
more doubts.

I have made an app earlier using MS Access. In it, you can create a
form which has a 'details' section with one row of components
corresponding to the fields in your table. When the form is created
and executed, this section expands depending on the number of records
in the table. It is something similar to the creation of reports. Is
there a way of doing this in VC#.

Thanks
Nitin