473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ADSI Datagrid Sorting???

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)(objec tClass=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("physicalDeliveryOfficeNam e") 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
Nov 19 '05 #1
0 873

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.