By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

Nested Datagrid error checking Help

P: 40
I have One Datagrid with a dataset that calls two tables - the First table is the table the user will be editing - which edited on the grid or in a textbox - as the user edits the grid - that info is automatically updated onto the database - My problem is - when user goes to the nested table the application is still looking for parameters to update the database - which is causing errors - how will I prevent this from happening on the second table here his my code snippent - I know it has to have something to do with MyDataset.Tables(1) but I can not get the syntax down for this at all.

Expand|Select|Wrap|Line Numbers
  1. Dim command1 As New SqlCommand("Select * FROM LateOrders_Header_view", cnn1)
  2. Dim command2 As New SqlCommand("Select * from LateOrders_Line_view", cnn1)
  3. 'Dim SqlReader As SqlDataReader
  4. Try
  5. cnn1.Open()
  7. 'Debug.WriteLine(cnn1.ConnectionString)
  8. Dim dt As New DataTable("LateOrders_Header_view")
  9. dgOrderReport.DataSource = dt
  10. Dim DirAdapter As New SqlDataAdapter(command1)
  11. Dim DirAdapter2 As New SqlDataAdapter(command2)
  12. Dim dc1 As DataColumn
  13. Dim dc3 As DataColumn
  14. Dim datarelation As DataRelation
  16. MyDataSet = New DataSet
  17. MyDataSet = New DataSet
  18. DirAdapter.TableMappings.Add("table1", "LateOrders_Header_view")
  19. DirAdapter.TableMappings.Add("table2", "LateOrders_line_view")
  21. DirAdapter.Fill(MyDataSet, "LateOrders_Header_view")
  22. DirAdapter2.Fill(MyDataSet2, "LateOrders_Line_view")
  24. dc1 = MyDataSet.Tables("LateOrders_Header_view").Columns("order_no")
  25. dc3 = MyDataSet.Tables("LateOrders_Line_view").Columns("order_no")
  26. datarelation = New DataRelation("Line View", dc1, dc3)
  27. MyDataSet.Relations.Add(datarelation)
  28. 'dc3.ReadOnly = True
  30. dgOrderReport.DataSource = MyDataSet.DefaultViewManager '.CreateDataView.Tables("LateOrders_Header_view").DefaultView
  31. dgOrderReport.DataMember = "LateOrders_header_view"
'This controls the grid click event - This is where I believe I need to add something to let it know that this dosent apply to the second table
How do I let it know not to do this (below) for second table.

Expand|Select|Wrap|Line Numbers
  1. Private Sub dgOrderReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgOrderReport.Click
  2. Try
  4. txtReason.Text = dgOrderReport.Item(dgOrderReport.CurrentRowIndex, 4) & ""
  5. txtReason.Enabled = False
  6. chkReason.Checked = False
  8. Catch ex As Exception
  9. MessageBox.Show(ex.Message)
  10. End Try
  12. End Sub 

Any Ideas....
Sep 7 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.