Hi,
I'm using a Bitwise Enum as a Datasource for a repeater control in which each line has a checkbox. When the user saves data, enum values corresponding to the checked boxes are saved into a single database field.
However, when the user comes to edit the data, obviously I need to pre-populate the repeater with the existing values. I can do this in a straightforward value by interating through the possible values of the enum and checking boxes accordingly. However, ideally I'd really like my code to remain independent of changes to the data: so if I change the or add to the values in the Enum, my code will still work without changing the code in my control.
It seems the obvious thing to do is try to iterate through the existing values in the enum field once I've got it back from the database. In other words, if the saved value corresponds to two selections out of the several in the enum, I need to loop through just those two. However I can see no method or property that I can use to do this. Can anyone point me in the right direction?
A sample ... which might help make sense of this ... is that I can get sort of the effect I want by casting it to a string and splitting it, but it's clumsy (comsPrefs is the enum in question)
Dim selectedPrefs As String = comsPrefs.ToString()
Dim splitStr() As String = selectedPrefs.Split(","c)
Dim i As Integer
For i = 0 To splitStr.Length - 1
'do some cool stuff
Next
Cheers, Matt