ADSI Datagrid Sorting???

G

Guest

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 DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objectClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll


Dim topRow As DataRow = ds.Tables("contacts").NewRow
topRow("&nbsp;") = "<img src='../images/user.gif'>"

If res.Properties.Contains("sn") And
res.Properties.Contains("givenName") And res.Properties.Contains("Initials")
Then
topRow("Name") = CStr(res.Properties("givenName")(0)) & ", "
& CStr(res.Properties("sn")(0)) & " " & CStr(res.Properties("Initials")(0))
Else
topRow("Name") = ""
End If

If res.Properties.Contains("physicalDeliveryOfficeName") Then
topRow("Dept.") =
CStr(res.Properties("physicalDeliveryOfficeName")(0))
Else
topRow("Dept.") = ""
End If

If res.Properties.Contains("telephoneNumber") Then
topRow("Ext") = CStr(res.Properties("telephoneNumber")(0))
Else
topRow("Ext") = ""
End If

If res.Properties.Contains("mail") Then
topRow("Email") = CStr(res.Properties("mail")(0))
Else
topRow("Email") = ""
End If


ds.Tables("contacts").Rows.Add(topRow)




Next
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()

End Sub



Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("contacts")
tbcontacts.Columns.Add("&nbsp;", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Name", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Dept.", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Ext", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Email", System.Type.GetType("System.String"))
ds.Tables.Add(tbcontacts)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top