deleting a record in datatable

hanntd

New member
Joined
Feb 10, 2006
Messages
3
Programming Experience
3-5
I have a problem with deleting on the form that has 2 level
For example, I have 2 table:
User:
UserID UserName
Admin Administrator
FIN Finance
MAR Marketing
-----------------------------------
UserGroup:
UserID GroupID
Admin ADMIN
FIN AP
FIN AR
FIN GL
MAR OM
MAR IN
on the form_load event I load data into 2 datatable in one dataset and add
Relation for them also. When I click the button for navigating I want to refresh
the child binding control and I used dataview.rowfilter. The system work properly
and display correct the child data coresponding to parent table. But the problem
when I want to delete the current child row, I cannot delete correct the current
child record binding to form control. I tried to debug and know the problem, when
I use the rowfilter the position system returned when I use
Me.CommandBars(0).FindForm.BindingContext(dsData.Tables("UserGroup")).P
osition was not equal real position in this table.
Ex: if the current child row display is: " FIN, AR" system return 1 but the real
postion is 2 (0: Admin,ADMIN; 1:FIN,AP; 2:FIN,AR)
So if i use Me.CommandBars(0).FindForm.BindingContext(dsData,
dsData.Tables("UserGroup").TableName).RemoveAt(Me.CommandBars(0).FindF
orm.BindingContext(dsData.Tables("UserGroup")).Position) the system will
remove another row (FIN, AP).
I try to use other way by using datatable.clear and reload data into this
datatable with select command has conditional for filter. It worked ok now for
deleting child table but when I delete the parent row it didn't delete child row
automatically. If i use the first way the child row will be deleleted automatically.
Pls ignore in case the second level is bound to the datagrid, It's quite simple in
this case. for two these tables just is the sample, my problem only happen in
case the second level has many information that we cannot display by
datagird(difficult for viewing) so that we have to bind to textbox.
Everybody pls help me on this problem. I was stucked in this problem a long
time.
thanks in advance
Han
 

Attachments

  • usergrouperr.JPG
    usergrouperr.JPG
    44.6 KB · Views: 93
Back
Top