473,503 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HyperLinkColumn problem

Hi,

I create from my CS code an HyperLinkColumn, and add it to a DataGrid
before binding data...

Then, I need to use text from that Column in ItemDataBound...

I do this:

e.Item.Cells[2].Text = e.Item.Cells[0].Text + "MyStuff";

the problem is that my Cell 2 only shows MyStuff instead of cell's 0
text AND MyStuff...

I think the problem cames from the fact that I create 'source' cell by
code, but I can't do it another way...

Any idea ?

TIA
Nov 19 '05 #1
8 1066
Are u checking for ??
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
End iF
--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"Franck Diastein" wrote:
Hi,

I create from my CS code an HyperLinkColumn, and add it to a DataGrid
before binding data...

Then, I need to use text from that Column in ItemDataBound...

I do this:

e.Item.Cells[2].Text = e.Item.Cells[0].Text + "MyStuff";

the problem is that my Cell 2 only shows MyStuff instead of cell's 0
text AND MyStuff...

I think the problem cames from the fact that I create 'source' cell by
code, but I can't do it another way...

Any idea ?

TIA

Nov 19 '05 #2
Franck,

Read Your Hyperlink text like below.

( (Hyperlink)e.item.findcontrol("HyperlinkId")).Text .

The text you're trying to read from cell[0] returns the literal text
in the cell. The hyperlink you have added would be a control added to
the control tree with the cell as the parent tree.

-Souri

Nov 19 '05 #3
yes

vinay wrote:
Are u checking for ??
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
End iF

Nov 19 '05 #4
I understand what you say, but that doesn't work :-(

I have defined nothing in aspx side...

This is what I have done:

HyperLinkColumn hlcLink = new HyperLinkColumn();
hlcLink.HeaderText = "Rep";
hlcLink.DataTextField = "Name";
hlcLink.DataNavigateUrlField = "Name";
hlcLink.DataNavigateUrlFormatString = classes.appSettings.SvnURI + "{0}";

dgDirectories.Columns.AddAt(0,hlcLink );

I tried this:

e.Item.Cells[2].Text = ((HyperLink ) e.Item.FindControl("hlcLink")).Text;

But had this error:

Object reference not set to an instance of an object.

souri challa wrote:
Franck,

Read Your Hyperlink text like below.

( (Hyperlink)e.item.findcontrol("HyperlinkId")).Text .

The text you're trying to read from cell[0] returns the literal text
in the cell. The hyperlink you have added would be a control added to
the control tree with the cell as the parent tree.

-Souri

Nov 19 '05 #5
You need to find the control by its ID. Try setting an explict ID to
the control right after you create it and use it in FindControl.

Nov 19 '05 #6
I just noticed that you're trying to add a column not control in the
cell.
try the following

e.Item.Cells[2].Text = ((HyperLink)e.Item.Cells[0].Controls[0]).Text;

HTH,
Souri

Nov 19 '05 #7
I don't have ID property for hlcLink...

souri challa wrote:
You need to find the control by its ID. Try setting an explict ID to
the control right after you create it and use it in FindControl.

Nov 19 '05 #8
This works like a charm :-)

Thnaks

King regards !!!

souri challa wrote:
I just noticed that you're trying to add a column not control in the
cell.
try the following

e.Item.Cells[2].Text = ((HyperLink)e.Item.Cells[0].Controls[0]).Text;

HTH,
Souri

Nov 19 '05 #9

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

Similar topics

0
4827
by: Jongmin | last post by:
Hi! I am making HyperLinkColumn in datagrid. It is simple to make the hyerlinkcolumn with one datafield. <asp:HyperLinkColumn Text="NAME" DataNavigateUrlField="NAME"...
1
1439
by: Dmitri Manushin | last post by:
Hi all, i have HyperLinkColumn in DataGrid <asp:HyperLinkColumn DataNavigateUrlField="PostID" DataNavigateUrlFormatString="http://localhost/forum/posts.aspx?id={0}" DataTextField="Subject"...
3
3369
by: SStory | last post by:
I have a style sheet for my site. It has various classes in it. It has <A: styles defined for all anchor tags. I have a datagrid in ASP.NET with a stylesheet linked to the page. It defines...
3
3357
by: TJS | last post by:
how can I encrypt the querystring values for a HyperLinkColumn ? in example below I would like to encrypt value for field1 ======================================================...
0
1076
by: Atif Jalal | last post by:
I am using a Datagrid control and one of its column is a 'HyperLinkColumn'. The link text for this HyperLinkColumn is sometimes beyond 100 characters. I would like to display the link on multi-line...
3
3074
by: Maziar Aflatoun | last post by:
Hi everyone, Does anyone know how I can apply the css 'linksmall' to my hyperlink in my datagrid? I have the following and it doesn't work <asp:HyperLinkColumn Text="Edit"...
10
1735
by: tshad | last post by:
I have a Datagrid with a column: <asp:HyperLinkColumn DataTextField="JobTitle" DataNavigateUrlField="PositionID" DataNavigateUrlFormatString="AddNewPositions.aspx?PositionID={0}"...
1
1771
by: Sean Aitken | last post by:
Does anyone know the easiest way to trim the whitespace from a CHAR(...) bound value coming from a database and used with a HyperLinkColumn? In this case, the column is setup using: .......
1
2812
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters...
4
2244
by: rcoco | last post by:
Hi all, I have this big problem with hyperlinks I would appriciate any help please. My web site has two datagrids on the same page. And one has a list of names of the users which are in a...
0
7204
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
7091
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
7282
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,...
0
7342
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
6998
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
5586
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
3171
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...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
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...

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.