Does anyone have any idea how to get the text out of a hyperlink column in a
web datagrid?
It's a hyperlink column, not a template column so findcontrol does not work
and there is no apparent name to look for.
myGridItem.cell s(0).controls(0 ) shows no text properties or anything that
points to or contains the text.
It seems quite hidden.
G 6 1920
A Cell(0).Text should work
"GaryB" <gb@nospam.co m> wrote in message
news:eE******** ******@TK2MSFTN GP12.phx.gbl... Does anyone have any idea how to get the text out of a hyperlink column in a web datagrid?
It's a hyperlink column, not a template column so findcontrol does not work and there is no apparent name to look for.
myGridItem.cell s(0).controls(0 ) shows no text properties or anything that points to or contains the text.
It seems quite hidden.
G
No, it does not. That's the whole point of the question. When a column is
a hyperlink column, the text is not present in cell(n).text.
G
"George Durzi" <gd****@hotmail .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. A Cell(0).Text should work
"GaryB" <gb@nospam.co m> wrote in message news:eE******** ******@TK2MSFTN GP12.phx.gbl... Does anyone have any idea how to get the text out of a hyperlink column in a web datagrid?
It's a hyperlink column, not a template column so findcontrol does not work and there is no apparent name to look for.
myGridItem.cell s(0).controls(0 ) shows no text properties or anything that points to or contains the text.
It seems quite hidden.
G
Im my experiment it renders into the second control. You can cast
item.Cells(0).C ontrols(1) to a HyperLink control to pull the Text and
NavigateUrl properties.
Indexing into the control array always makes me nervous. I don't know
when MS might change how the controls render and that would break some
code. If I need to dig something out I stick to templated columns with
named controls. Know what I mean?
--
Scott http://www.OdeToCode.com/blogs/scott/
On Mon, 1 Nov 2004 17:55:20 -0700, "George Durzi" <gd****@hotmail .com>
wrote: A Cell(0).Text should work
"GaryB" <gb@nospam.co m> wrote in message news:eE******* *******@TK2MSFT NGP12.phx.gbl.. . Does anyone have any idea how to get the text out of a hyperlink column in a web datagrid?
It's a hyperlink column, not a template column so findcontrol does not work and there is no apparent name to look for.
myGridItem.cell s(0).controls(0 ) shows no text properties or anything that points to or contains the text.
It seems quite hidden.
G
Thanks for Scott's informative suggestion.
Hi Gary,
As Scott has mentioned, since the HyperLink columns will contain a
HyperLink control in it's Cell, we need to retrieve the HyperLink control
first , then access its properties. For example:
private void btnSubmit_Click (object sender, System.EventArg s e)
{
foreach(DataGri dItem dgi in dgData.Items)
{
HyperLink hl = dgi.Cells[0].Controls[0] as HyperLink;
if(hl!=null)
{
Response.Write( "<br>Text: " + hl.Text + " Link: " + hl.NavigateUrl) ;
}
}
}
thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thats it! I knew it was in cells(3).contro ls(0) but I was looking for it
directly there. Of course I have to dimension it as a hyperlink and there
it is.
Thanks.
About what Scott said, do you think this kind of thing might change?
Gary
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:Mo******** *****@cpmsftngx a10.phx.gbl... Thanks for Scott's informative suggestion.
Hi Gary,
As Scott has mentioned, since the HyperLink columns will contain a HyperLink control in it's Cell, we need to retrieve the HyperLink control first , then access its properties. For example:
private void btnSubmit_Click (object sender, System.EventArg s e) { foreach(DataGri dItem dgi in dgData.Items) { HyperLink hl = dgi.Cells[0].Controls[0] as HyperLink; if(hl!=null) {
Response.Write( "<br>Text: " + hl.Text + " Link: " + hl.NavigateUrl) ; } } }
thanks.
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Hi Gary,
Thanks for the followup. Yes, Scott's worry is reasonable since the
internal implemention of the datagrid's Buildin ColumnType may changed in
new versions. So it's better that we use a custom Template Column and put a
HyperLink control which has a specified "id" property so that we can
reference it via "FindContro l".
Also, do need to put the following code when accessing sub controls via
index on webform so as not to get "null reference exception.".
HyperLink hl = dgi.Cells[0].Controls[0] as HyperLink;
if(hl!=null)
{
}
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jib |
last post by:
How do I redirect a hyperlink column's URL when the URL doesn't exist? Is
it possible to set a default URL for the Hyperlink button?
Thanks,
Jib
|
by: Soul |
last post by:
Hi,
I have a column in my DataGrid which is a Hyperlink Column. Everything work
fine except when I try to get the text of the column using
this.DataGrid.SelectedItem.Cells.Text, I got blank value!!
People from some forum suggest to use ((LinkButton)
this.DataGrid.SelectedItem.Cells.Controls).Text, but I got
"Specified cast is not valid" error.
|
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 selected value of the drop down...
here is how it looks like
<asp:datagrid....>
....
<asp:TemplateColumn>
<ItemTemplate>
|
by: epigram |
last post by:
I'm using the DataGrid with AutoGenerateColumns set to false and choosing
which columns I want in the grid by using the <Columns> attribute. What I
want to do is to create a hyperlink out of one of the columns that I am
displaying, but in order to build this link, I need a value that is in my
SELECT clause, but is not being displayed via a BoundColumn.
Say I have a query: SELECT ID, Name FROM Companies
Here, ID is the PK. I am only...
|
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"))
| |
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)")...
|
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.
|
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...
|
by: jeguillo |
last post by:
I am trying to retrieve the text within each cell in a datagrid in
order to change the color of each cell, depending on the value within
that cell.
This works fine on the cells that are bound columns, but returns an
empty string for the cells that are hyperlink columns.
Here is the code to retrive the text:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |