Web Development

General discussion


.NET Dataview Dilemma

By Joseph Chancellor ·
I'm programming a VB.NET component to provide the middle-layer access to an SQL database, and having some problems with the Dataview object.

I'm trying to handle a many-to-many relationship (accomplished via a linking table). My goal is to end upwith 2 boxs on the GUI, with an ADD and REMOVE button. One box has a list of all items that have been chosed, and the other has a list of what hasn't been chosen. Bost lists are databound from different dataview objects -- one object is a list of all available choices from my choice table that is filtered by removing all rows that do not have child rows in the linking table, the other table is filtered by all rows that do.

That's all working fine, but this is the issue I run into: If I change the linking table (either adding or removing a row) the dataview object doesn't show me the updated rows. I even have the rowstate filter on the dataviews set to CURRENTROWS. The dataview object is exposed as a property, which I bind to a listbox on the Windows form. Basically I call the method to either add or remove the choice, and then rebind the dataview. It looks the same. If I click twice, I get an ERROR, as the item has been removed already from the dataset, so I know the method is working!

Do I need to call some method or something to resort my dataview objects? Does my dataview not update since I'm sorting it by the presence/absence of child rows in another dattable? The only work-around has been to update the datatable to thedatabase each time I add/remove a choice (in the method), and then call the constructor again, and the dataview property is a correct represenation of the data. I'm trying to not commit changes to the database until I'm happy, so this isn't a good work-around.

I may be overlooking something really silly -- my programming skills aren't great, and I'm fairly new to .NET so it's possible. Any help would be appreciated.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

.NET Dataview Dilemma

by Joseph Chancellor In reply to .NET Dataview Dilemma

Here's my code for the dataview objects...
_SecurityApplied.RowFilter = ("Count(Child(EmailDomainSecurityITEmailDomainSecurity).fkEmailSecurityID) > 0")
_SecurityApplied.RowStateFilter = DataViewRowState.CurrentRows
_SecurityChoices.RowFilter = ("Isnull(Count(Child(EmailDomainSecurityITEmailDomainSecurity).fkEmailSecurityID), 0) = 0 ")
_SecurityChoices.RowStateFilter = DataViewRowState.CurrentRows

Also, here is my add choice procedure...
Dim mynewrow As DataRow
mynewrow= EmailDomain.Tables("ITEmailDomainSecurity").NewRow
mynewrow("fkEmailDomainID") = _EmailDomainID
mynewrow("fkEmailSecurityID") = EmailSecurityID

When I call the dataview object again, it hasn't changed!

Related Discussions

Related Forums