473,800 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable and Hyperlink Column

Can someone please tell me how I create a hyperlink column in a datatable...

I have the following Sub that creates a datatable from my Active Directory
but I would like to be able to turn the email column into a link so it
automatically opens an email!

I realise I have to create a mailto: link but am not sure how you create a
link column programatically in a datatable in ASP.NET

Thanks
....CODE...

Sub BindGrid(Option al ByVal alpha As String = "")

Dim strADPath As String
strADPath = "netdomain.usem bassy.dk"

Dim de As DirectoryEntry = New DirectoryEntry( "LDAP://" & strADPath,
"netadmin", "N37au7h0R" )
Dim src As DirectorySearch er

If alpha = "" Then
DataGrid1.Allow Paging = True
src = New
DirectorySearch er("(&(objectCa tegory=Person)( objectClass=use r))")
Else
DataGrid1.Allow Paging = False
src = New
DirectorySearch er("(&(objectCa tegory=Person)( objectClass=use r)(sn=" & alpha &
"*))")

End If

src.SearchRoot = de
src.SearchScope = SearchScope.Sub tree
For Each res As SearchResult In src.FindAll
Dim dr As DataRow = ds.Tables("cont acts").NewRow
dr("&nbsp;") = "<img src='../images/user.gif'>"

If res.Properties. Contains("sn") And
res.Properties. Contains("given Name") And res.Properties. Contains("Initi als")
Then
dr("Name") = CStr(res.Proper ties("givenName ")(0)) & ", " &
CStr(res.Proper ties("sn")(0)) & " " & CStr(res.Proper ties("Initials" )(0))
Else
dr("Name") = ""
End If

If res.Properties. Contains("physi calDeliveryOffi ceName") Then
dr("Dept.") =
CStr(res.Proper ties("physicalD eliveryOfficeNa me")(0))
Else
dr("Dept.") = ""
End If

If res.Properties. Contains("telep honeNumber") Then
Dim TeleNumber As String =
CStr(res.Proper ties("telephone Number")(0))
dr("Ext") = "#" & Right(TeleNumbe r, Len(TeleNumber) -
InStr(TeleNumbe r, "1"))
Else
dr("Ext") = ""
End If

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

ds.Tables("cont acts").Rows.Add (dr)

Next
' Binds Contact data from Active Directory to DataGrid
DataGrid1.DataS ource = ds.Tables("cont acts")
DataGrid1.DataB ind()
End Sub
Nov 19 '05 #1
0 1955

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

Similar topics

3
2893
by: Maulin Vasavada | last post by:
Hi, I have DataTable and I want to actually put a LinkLabel in one the columns where I can click an do something BUT it seems I can't put LinkLabel in the table cell of DataTable. So as an alternative I thought if I can detect double click events on a cell I can get the text in there and do something but I am not able to do so. Please let me know if I have to provide more information to help solve this problem.
2
2631
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four columns. Three are databound to a dataset and one is a template column. I need to be able to access each item in the template column (getting access to the hyperlink) then adding an attribute to call some client side code. Does anyone know...
9
15032
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring = datagrid.Items(rownumber).Cells.Item(column number).Text returns a blank string. It seems to work ok for the other columns that are just regular datagrid columns, not hyperlink types. Thanks. -- Paul G Software engineer.
3
15410
by: Tim::.. | last post by:
I currently have the following datagrid but want to turn the name and email column into a hyperlink in the codebehind! Can someone please tell me how I achieve this! Thanks Private Sub createTable() Dim tbcontacts As DataTable = New DataTable("contacts") tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
2
2260
by: Jason | last post by:
I have a data grid with a hyperlink column. The hyperlink is created by a class that extracts the link from an XML Document. How can I populate the hyperlink column in the data grid with the value (link) returned from my class method? I have to send the company ticker to the class in order to get the correct link. I tried embedding the method into the NavigateURL property of the data grid (i.e. NavigateUrl="GetCompanyLink(Ticker)")...
10
1946
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it. Do you have ideas about it? Thanks.
19
3562
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2. I've thought of using a hidden field and then calling Request.Form("hdnClickedLinkText") in the...
3
3547
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
1
1688
by: arun.hallan | last post by:
Hi, I have a DataTable with say three items, an structureid, a name and description. Then i have a datagrid with one hyperlink which uses the id. The code in the page is: <asp:HyperLinkColumn Target="_blank" DataNavigateUrlField="StructureId"
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10035
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9090
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.