Referring to this thread: Algorithm to count the time that occured on the same period, how to bind the dictionary to the GridView? Pls take a look to the answer.
I t
Here is a Gridview
<asp:GridView ID="GV" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Key" HeaderText="Dictionary Key" />
<asp:BoundField DataField="Value" HeaderText="Dictionary Value" />
</Columns>
</asp:GridView>
Here is code to bind a dictionary to that Gridview
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim D As New Dictionary(Of Integer, String)
D.Add(1, "One")
D.Add(2, "Two")
D.Add(3, "Three")
GV.DataSource = D
GV.DataBind()
End Sub
Here is the output
What if my Value of of some type "MyClass?"
The Gridview will execute the ToString
function of MyClass
, per "Value" cell.
In your example, Override the ToString
function on this class
Public Class TimeRangeCounter
Property ExactRangeMatch as Integer
Property SubRangeMatch as Integer
End Class
This is necessary because your "Value" is of time TimeRangeCounter
Summary
The Author's code had two problems.