473,385 Members | 1,325 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,385 software developers and data experts.

ASP NET Hyperlink column HELP

Hi,

Hi currently i have a datagrid

it have 3 column

the 1st column I using databind.

however, for column 2 and 3, i never using databind,
I using datagrid1_onitemdatabound command to manually

insert the data into the cell.

like

e.item.cells[2].text = XX

can i make this column as hyperlink?
I found that I only can make it if it is using databind.
Mar 8 '07 #1
8 1168
Hi,


I have a hyperlink column in ht datagrid

which is

column1 column2

unfortunately, i m get the column value by code behind - onitemdatabound
for example

e.item.cells[0].text = XXX.tostring();
e.item.cells[1].text = xxx.tostring();

My datagrid can't display the columns value as hyperlink.

If i use SQL databind, it work fine
Mar 8 '07 #2
when you created hyperlink column, in grid it will be added a HyperLink
Control. so you have to convert that to apropriate control and give the data.

try this
((HyperLink)e.item.cells[0].Controls[0]).text = XXX.tostring()
Mar 8 '07 #3
kenobewan
4,871 Expert 4TB
Here is an example that may help:
Expand|Select|Wrap|Line Numbers
  1. Public Sub myDataGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs)
  2.  
  3.       'Only perform this code if we are looking at the footer
  4.       If(e.Item.ItemType = ListItemType.Footer )
  5.          Dim myHyperLink As HyperLink = new HyperLink()
  6.  
  7.          'This traps an error if no id is present in the QueryString   
  8.          If Not Request.QueryString("id") = Nothing Then
  9.              myHyperLink.Text = "Add Detail"
  10.              myHyperLink.NavigateURL = "adddetail.aspx?id=" & Request.QueryString("id")
  11.          Else
  12.              myHyperLink.Text = "Cannot Add Detail"
  13.          End If
  14.  
  15.          'Cells is Zero Based
  16.          '1 is the column number where we want to add the hyperlink
  17.          e.Item.Cells(1).Controls.Add(myHyperLink)
  18.       End If
  19.  
  20.   End Sub
Mar 8 '07 #4
Try This:

Create a HyperLink control and add to the controls list


HyperLink hl = new HyperLink();
hl.Text = "SOmething";
e.cells[2].controls.add(hl)
Mar 8 '07 #5
kenobewan
4,871 Expert 4TB
Please do not repost questions it is against site rules. I have merged these two threads. Thanks.
Mar 8 '07 #6
I really feel appreciated and thank you, much...


when you created hyperlink column, in grid it will be added a HyperLink
Control. so you have to convert that to apropriate control and give the data.

try this
((HyperLink)e.item.cells[0].Controls[0]).text = XXX.tostring()
Mar 8 '07 #7
Thank for your replied, thank much



Here is an example that may help:
Expand|Select|Wrap|Line Numbers
  1. Public Sub myDataGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs)
  2.  
  3.       'Only perform this code if we are looking at the footer
  4.       If(e.Item.ItemType = ListItemType.Footer )
  5.          Dim myHyperLink As HyperLink = new HyperLink()
  6.  
  7.          'This traps an error if no id is present in the QueryString   
  8.          If Not Request.QueryString("id") = Nothing Then
  9.              myHyperLink.Text = "Add Detail"
  10.              myHyperLink.NavigateURL = "adddetail.aspx?id=" & Request.QueryString("id")
  11.          Else
  12.              myHyperLink.Text = "Cannot Add Detail"
  13.          End If
  14.  
  15.          'Cells is Zero Based
  16.          '1 is the column number where we want to add the hyperlink
  17.          e.Item.Cells(1).Controls.Add(myHyperLink)
  18.       End If
  19.  
  20.   End Sub
Mar 8 '07 #8
Thank for your replied, thank much

Try This:

Create a HyperLink control and add to the controls list


HyperLink hl = new HyperLink();
hl.Text = "SOmething";
e.cells[2].controls.add(hl)
Mar 8 '07 #9

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

Similar topics

2
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...
1
by: Pat | last post by:
All, What I want to do: ******************* Click on a hyperlink in the last column in a datagrid, have it grab a value in the fourth column in the same row and send it to the codehind into a...
9
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
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...
3
by: Raja | last post by:
I have a datagrid, it has dropdown box as a column and i have one more column that has hyperlink. The NavigateURL for the hyperlink is to open a new window with a query stirng parameter as the...
2
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...
10
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
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...
3
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...
1
by: Valli | last post by:
Hi, I need to display an hyperlink column in gridview where if the user clicks that column the page should move to the selected page. I have got help from this group & started using template...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.