I wanted to reuse the data that I was pulling for my Gridview (rather than make a separate call to the DB) so I put this code in the RowDataBound event to collect all the distinct server names:
Dim testServerList As New NameValueCollection
Dim name, value As String
If e.Row.RowType = DataControlRowType.DataRow Then
name = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerName").ToString()
value = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerId").ToString()
If Not name.Equals(String.Empty) AndAlso testServerList(name) = Nothing Then
testServerList.Add(name, value)
End If
If e.Row.RowType = DataControlRowType.DataRow Then
name = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerName").ToString()
value = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerId").ToString()
If Not name.Equals(String.Empty) AndAlso testServerList(name) = Nothing Then
testServerList.Add(name, value)
End If
And then I wanted to sort the data:
Dim sortedKeys() As String
sortedKeys = testServerList.AllKeys
Array.Sort(sortedKeys)
sortedKeys = testServerList.AllKeys
Array.Sort(sortedKeys)
No comments:
Post a Comment