DataGrid Question

  • Thread starter Thread starter Bob Day
  • Start date Start date
B

Bob Day

Using vs 2003, vb.net, sql msde...

1) A datagrid with Parent and Child bound tables. Everything works fine.

In Datagrid, with only the ParentTable displayed ,
it is easy to UPDATE the parent columns with standard ADO.NET commands (i.e.
ParentTable.Column1 = New Value).

In same Datagrid, with ChildTable displayed ,the
ParentTable columns move up into some type of header over the ChildTable.
In this situation, how do you modify the values of the ParentTable (with the
ChildTable still displayed). ADO.NET commands (i.e. ParentTable.Column1 =
New Value) that worked above no longer work (they give an error).

2) With ChildTable displayed, rows are added constantly. How do you keep
the last row added visible in the DataGrid? You can, of course, scroll
down.

Please advise.

Bob Day
 
Hi Bob,
1) A datagrid with Parent and Child bound tables. Everything works fine.

In Datagrid, with only the ParentTable displayed ,
it is easy to UPDATE the parent columns with standard ADO.NET commands (i.e.
ParentTable.Column1 = New Value).

In same Datagrid, with ChildTable displayed ,the
ParentTable columns move up into some type of header over the ChildTable.
In this situation, how do you modify the values of the ParentTable (with the
ChildTable still displayed). ADO.NET commands (i.e. ParentTable.Column1 =
New Value) that worked above no longer work (they give an error).
Based on my experience, you want to make some change to the dataset and
update it into the database.
If so I can not reproduce the problem.

I test according to the KB link below.
308057 HOW TO: Display Parent and Child Fields Together in a Windows Forms
http://support.microsoft.com/?id=308057


320301 HOW TO: Update Parent-Child Data with an Identity Column from a
Windows
http://support.microsoft.com/?id=320301
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ds.Tables("Cust").Rows(4).Item("CompanyName") = "Test"
SqlDataAdapter.Update(ds , "Cust")
End Sub

You may perform the test and let me know the result.

If I misunderstand your meaning ,please feel free to let me know.

2) With ChildTable displayed, rows are added constantly. How do you keep
the last row added visible in the DataGrid? You can, of course, scroll
down.
You may try to set the CurrentRowIndex to the new added row's index.
e.g.
DataGrid1.CurrentRowIndex = 20



Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top