Hi,
Can someone tell me how I sort a datagrid when using ActiveDirectory as my
Datasource! I would like to be able to add sorting to my datagrid but don't
know how to achive it!
Thanks for any advice!
Dim src As DirectorySearch er = New
DirectorySearch er("(&(objectCa tegory=Person)( objectClass=use r))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Sub tree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("cont acts").NewRow
topRow(" " ) = "<img src='../images/user.gif'>"
If res.Properties. Contains("sn") And
res.Properties. Contains("given Name") And res.Properties. Contains("Initi als")
Then
topRow("Name") = CStr(res.Proper ties("givenName ")(0)) & ", "
& CStr(res.Proper ties("sn")(0)) & " " & CStr(res.Proper ties("Initials" )(0))
Else
topRow("Name") = ""
End If
If res.Properties. Contains("physi calDeliveryOffi ceName") Then
topRow("Dept.") =
CStr(res.Proper ties("physicalD eliveryOfficeNa me")(0))
Else
topRow("Dept.") = ""
End If
If res.Properties. Contains("telep honeNumber") Then
topRow("Ext") = CStr(res.Proper ties("telephone Number")(0))
Else
topRow("Ext") = ""
End If
If res.Properties. Contains("mail" ) Then
topRow("Email") = CStr(res.Proper ties("mail")(0) )
Else
topRow("Email") = ""
End If
ds.Tables("cont acts").Rows.Add (topRow)
Next
DataGrid1.DataS ource = ds.Tables("cont acts")
DataGrid1.DataB ind()
End Sub
Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("cont acts")
tbcontacts.Colu mns.Add(" ", System.Type.Get Type("System.St ring"))
tbcontacts.Colu mns.Add("Name", System.Type.Get Type("System.St ring"))
tbcontacts.Colu mns.Add("Dept." , System.Type.Get Type("System.St ring"))
tbcontacts.Colu mns.Add("Ext", System.Type.Get Type("System.St ring"))
tbcontacts.Colu mns.Add("Email" , System.Type.Get Type("System.St ring"))
ds.Tables.Add(t bcontacts)
End Sub