The following is part of my code:
It's strange. the e.NewValues item can be cast to DictionaryEntry when using for each loop. But not working in for loop. I need to use for loop because I would like to compare e.OldValues and e.NewValues. Anyone met this issue ever?
VB.NET:
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
For Each entry As DictionaryEntry in e.NewValues
Response.Write(entry.Key.ToString()) 'This works
Next
For i As Integer = 0 to e.NewValues.Count - 1
Dim entry As DictionaryEntry = CType(DictionaryEntry, e.NewValues
(i))
Response.Write(entry.Key.ToString()) 'Runtime error : Specified cast is not valid
Next
End Sub