Alright, so the resolution for this ended up a bit convoluted. First I ended up having to store the search result set in Session
, so I built a Dictionary
for that:
Dim cache As Dictionary(Of String, ListDataModel) = New Dictionary(Of String, ListDataModel)
and added to that Dictionary
when building the ListDataModel
objects. Then, in the OnItemCommand
handler I ended up having the use Reflection
like this:
Dim cache As Dictionary(Of String, ListDataModel) = CType(Session("SearchResults"), Dictionary(Of String, ListDataModel))
If cache Is Nothing Then
Exit Sub
End If
Dim prop As PropertyInfo = e.CommandSource.GetType().GetProperty("Text")
If prop Is Nothing Then
Exit Sub
End If
Dim o As ListDataModel = cache(prop.GetValue(e.CommandSource, Nothing).ToString())
If o Is Nothing Then
Exit Sub
End If
As you can see I first pulled the "SearchResults" out of Session
, then tried to get at the Text
property of the DataGridLinkButton
. I had to use Reflection
because the DataGridLinkButton
class isn't visible. Then finally, if I found the property, I pulled off the value.
Though this works, and I hope that my solution is a by-product of something else weird in the application I'm maintaining, it's really not what I wanted to do in the end. This is a pretty poor interface to the DataGrid
-but it is ASP.NET 2.0 and so it's some old stuff!