473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Hyperlink in DataGrid Control

globalguideline
3 New Member
Hi!

I am using a DataGrid to show my table values. Some of the columns are showing
integer data. I need to show these IDs (Integer values) data as hyperlinks so that the
user can drill downward or get more details about the data. How to do this pleas if any one
knows gude me thanks a lot in advance.
Ali.
Mar 11 '08 #1
1 923
enggwaqas
19 New Member
Hi!

I am using a DataGrid to show my table values. Some of the columns are showing
integer data. I need to show these IDs (Integer values) data as hyperlinks so that the
user can drill downward or get more details about the data. How to do this pleas if any one
knows gude me thanks a lot in advance.
Ali.
There are two ways of doing this:

1. Using HyperLinkColumn colum, e.g:
Expand|Select|Wrap|Line Numbers
  1. <asp:DataGrid ID="dg" runat="server">
  2.             <Columns>
  3.                 <asp:HyperLinkColumn DataNavigateUrlFormatString="~/more.aspx?id={0}" DataNavigateUrlField="id" DataTextField="name" />
  4.             </Columns>
  5.         </asp:DataGrid>
2. Using ItemTemplate and <a> tags

Expand|Select|Wrap|Line Numbers
  1. <asp:DataGrid ID="dg" runat="server">
  2.             <Columns>                
  3.                 <asp:TemplateColumn>
  4.                     <ItemTemplate>
  5.                         <a href="more.aspx?id=<%#Eval("id") %>"><%#Eval("Name") %></a>
  6.                     </ItemTemplate>
  7.                 </asp:TemplateColumn>
  8.             </Columns>            
  9.         </asp:DataGrid>
In the above code "id" and "name" are the column names. Value in name column will be displayed with a hyperlink to more.aspx page with the value of id column in query string.
Mar 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4858
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
2223
by: Amir Eshterayeh | last post by:
Dear Friends I put a asp.net hyperlink control inside a datagrid as even a template column or hyperlink column but can not force datagrid to open a new window when I clicked on the hyperlink. I...
3
8656
by: Tom Bernsen | last post by:
This should be simple, I did it with a datagrid easily enough. Using VS Net 1.1, I want a label over the datagrid and a hyperlink below it (from WebForms toolbox), with BOTH of them centered (text...
2
1763
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of...
9
15003
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 =...
1
1848
by: D. Shane Fowlkes | last post by:
Hello All. I keep asking for help with this on the www.asp.net forums and nobody seems to be able to help. What I'm trying to accomplish is very simple. I simply want to create a Hyperlink...
10
1911
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...
19
3466
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...
4
4088
by: alun65 | last post by:
I'm attempting to programmatically build up some HTML in the code behind. Like so: // Create Hyperlink HyperLink link = new HyperLink(); link.NavigateUrl = "nice cat"; link.Text = "Cats...
6
10098
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
0
7175
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
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7120
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...
0
7542
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
5697
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,...
0
4754
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...
0
3247
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...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.