Guest gjnave Posted August 23, 2002 Posted August 23, 2002 I have racked my brains for the ENTIRE day trying to figure out how I can delete a single row from within a child table. This is my dataset structure: Organization Country City Ministry Worker Say that the Organization Table has One Entry, but the Country table has 3 entries (let's say Korea, USA, France) . And let's say that the City table has 3 entries under each of the 3 countries. (A total of 9 cities, which don't show together because they are related to different countries in the country table - or underneath different rows of the Country Table). Now, i want to delete the city of Denver (which is underneath the USA entry in the Country table). So i navigate to the correct relation and tell it which row to delete (in this case row #2) -- **CODE** dataset1.tables("country_city").rows(2).delete **End of Code** But aha! It didn't delete what I thought it should. Looking at the Datagrid, the row I want to delete being the 3rd down, you would think that that would be row #2. But what is really happening is that by telling the progam to go to "country_city" , I'm not just getting the cities for the USA, but for all the other countries also. So the index is not just for USA but for all the countries. SO here's the question. How can I tell the program to not include everything beneath all the rows in the Country table, but to only include what's beneath a specific row in the Table (Namely Denver)? Thank You Quote
Moderators Robby Posted August 24, 2002 Moderators Posted August 24, 2002 Using a Dataview, try this... If you are using another method, let me know. Dim strCurrentCountryID As String = DataViewCountry(DataGridCountry.CurrentRowIndex)("ID").ToString DataViewCity.RowFilter = "ID = " & strCurrentCountryID With DataGridCity .DataSource = DataViewCity End With Quote Visit...Bassic Software
Guest gjnave Posted August 24, 2002 Posted August 24, 2002 This is the line of code that I am working with... i found that if I preknow the row of the ParentTable that i can get the childrows for it and delete the approriate row (see below). ** dataR = ds1.tables(parentTable).Rows.item(1).getChildRows(relationName).getValue(datagrid1.currentCell.RowNumber) datar.delete ** However, in the realworld i won't preknow the Parents Row Number. I can get the Parent tables Row NAME, but not the index. Here is the code that I used. ** parentRowName = ds1.Tables(tableName).Rows.Item(DataGrid1.CurrentCell.RowNumber).GetParentRow(relationName).Item(0) ** Any ideas on how to get the index number? Quote
Moderators Robby Posted August 24, 2002 Moderators Posted August 24, 2002 This should get the Index... 'if you declare a Dataview, you can do this... Dim strCurrentCountryID As String = DataViewCountry(DataGridCountry.CurrentRowIndex)("ID").ToString Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.