473,750 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid-how to get cell value(hyperlink column)

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).Cell s.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.
Nov 18 '05 #1
9 15021
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
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).Cell s.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.

Nov 18 '05 #2
thanks for the information. Can this be in the page load routine as I am
getting an error trying to use e.? Thanks Paul.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
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).Cell s.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.


Nov 18 '05 #3
Hi,
I am getting an invalid cast on the following line, put it in a
ItemDataBound event.
CType(datagrid. Columns(0), HyperLinkColumn ).Text = "foobar"
just wondering if you may know what is wrong, thanks Paul.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
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).Cell s.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.


Nov 18 '05 #4
had the wrong column number.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
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).Cell s.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.


Nov 18 '05 #5
No. You have to use it in the ItemDataBound event of you datagrid.

Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:68******** *************** ***********@mic rosoft.com...
thanks for the information. Can this be in the page load routine as I am
getting an error trying to use e.? Thanks Paul.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
> 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).Cell s.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.


Nov 18 '05 #6
Hi almost have it working but not quite. The hyperlink column has a
different value for each row, data being returned from a stored procedure
then going into a dataset.
The code below returns the column text field of the hyperlink value but not
the actual cell value. I have

st_temp = CType(dg_search log.Columns(6), HyperLinkColumn ).DataTextField
and I get Data_Item_Numbe r which is the correct text field selected in the
data grid for that column but I need the cell values for each row out of the
column.
if I use
st_temp = CType(dg_search log.Columns(6), HyperLinkColumn ).Text
it returns a blank string.
"Greg Burns" wrote:
No. You have to use it in the ItemDataBound event of you datagrid.

Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:68******** *************** ***********@mic rosoft.com...
thanks for the information. Can this be in the page load routine as I am
getting an error trying to use e.? Thanks Paul.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
> 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).Cell s.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.


Nov 18 '05 #7
Looks like it is not possible to get the individual cell value of the
hyperlink column when using a data text field data source. The .text member
returns the string entered in the text entry of the property builder of the
datagrid. Using this sets the text the same for each row of the hyperlink
column. Setting the text field to a datasource will allow each row (cell
text) to be different for the hyperlink column but there does not seem to be
any method to return the value.

"Greg Burns" wrote:
No. You have to use it in the ItemDataBound event of you datagrid.

Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:68******** *************** ***********@mic rosoft.com...
thanks for the information. Can this be in the page load routine as I am
getting an error trying to use e.? Thanks Paul.

"Greg Burns" wrote:
If you had a HyperLink in a template column I would use this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
HyperLink)
.ToolTip = "Foobar"
.NavigateUrl = "Foobar"
.Text="Foobar"
End With
End If

But since you are using a HyperLinkColumn , I googled and found this:

If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
End If

HTH,
Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A4******** *************** ***********@mic rosoft.com...
> 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).Cell s.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.


Nov 18 '05 #8
Hmm. Sorry to hear that. Hadn't actually tried it.

Personally, I would just switch and make that column a template column. Add
a <asp:hyperlin k runat=server id=MyHyperLink /> control and use FindControl
to modify it in ItemDataBound.

Greg
"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Looks like it is not possible to get the individual cell value of the
hyperlink column when using a data text field data source. The .text
member
returns the string entered in the text entry of the property builder of
the
datagrid. Using this sets the text the same for each row of the hyperlink
column. Setting the text field to a datasource will allow each row (cell
text) to be different for the hyperlink column but there does not seem to
be
any method to return the value.

"Greg Burns" wrote:
No. You have to use it in the ItemDataBound event of you datagrid.

Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:68******** *************** ***********@mic rosoft.com...
> thanks for the information. Can this be in the page load routine as I
> am
> getting an error trying to use e.? Thanks Paul.
>
> "Greg Burns" wrote:
>
>> If you had a HyperLink in a template column I would use this:
>>
>> If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
>> ListItemType.Al ternatingItem Then
>> With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
>> HyperLink)
>> .ToolTip = "Foobar"
>> .NavigateUrl = "Foobar"
>> .Text="Foobar"
>> End With
>> End If
>>
>> But since you are using a HyperLinkColumn , I googled and found this:
>>
>> If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
>> ListItemType.Al ternatingItem Then
>> CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
>> End If
>>
>> HTH,
>> Greg
>>
>> "Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
>> news:A4******** *************** ***********@mic rosoft.com...
>> > 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).Cell s.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.
>>
>>
>>


Nov 18 '05 #9
ok sounds like a good idea. thanks.

"Greg Burns" wrote:
Hmm. Sorry to hear that. Hadn't actually tried it.

Personally, I would just switch and make that column a template column. Add
a <asp:hyperlin k runat=server id=MyHyperLink /> control and use FindControl
to modify it in ItemDataBound.

Greg
"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Looks like it is not possible to get the individual cell value of the
hyperlink column when using a data text field data source. The .text
member
returns the string entered in the text entry of the property builder of
the
datagrid. Using this sets the text the same for each row of the hyperlink
column. Setting the text field to a datasource will allow each row (cell
text) to be different for the hyperlink column but there does not seem to
be
any method to return the value.

"Greg Burns" wrote:
No. You have to use it in the ItemDataBound event of you datagrid.

Greg

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:68******** *************** ***********@mic rosoft.com...
> thanks for the information. Can this be in the page load routine as I
> am
> getting an error trying to use e.? Thanks Paul.
>
> "Greg Burns" wrote:
>
>> If you had a HyperLink in a template column I would use this:
>>
>> If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
>> ListItemType.Al ternatingItem Then
>> With CType(e.Item.Ce lls(column number).FindCon trol("control name"),
>> HyperLink)
>> .ToolTip = "Foobar"
>> .NavigateUrl = "Foobar"
>> .Text="Foobar"
>> End With
>> End If
>>
>> But since you are using a HyperLinkColumn , I googled and found this:
>>
>> If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
>> ListItemType.Al ternatingItem Then
>> CType(grid.Colu mns(0), HyperLinkColumn ).Text = "foobar"
>> End If
>>
>> HTH,
>> Greg
>>
>> "Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
>> news:A4******** *************** ***********@mic rosoft.com...
>> > 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).Cell s.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.
>>
>>
>>


Nov 18 '05 #10

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

Similar topics

0
1521
by: Cliff Benoist | last post by:
I have a case where I would like to add a textbox to a datagrid column header. I would like to use a user control or custom control to create a reusable control. The textbox will filter the results displayed in the datagrid. Is there a way to get at the column information of a datagrid as I described above?
0
806
by: Randy | last post by:
Hello, I'm trying to find out if there is a way to set a DataGrid column width (or tableStyle column width) to be auto-expanded to encompass the widest text in that column...to be auto-expanded rather than grabbing the widest text string that will be displayed in that column and setting the width. Is there a way to make the column width auto-expanded? Thanks
3
5374
by: bismarkjoe | last post by:
Hello, I am trying to set the widths on the columns of a DataGrid component, and I'm not sure if I'm doing it correctly. My code is below: //load some inital data table = db.GetDataTable( "SELECT 'Task' AS 'Type', title AS 'Title', IFNULL(u.name, 'Nobody') AS 'Assigned To' FROM tasks t LEFT JOIN users u ON t.assigned_to=u.user_id LIMIT 0, 30" ); grid.ReadOnly = true;
16
1679
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center"> <FooterTemplate> <asp:LinkButton CommandName="Insert" Text="<img src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
0
1196
by: Bidarkota | last post by:
Can i set the color of the entire DataGrid Column (for example to blue) when i click the header of the DataGrid Column. If it is possible please help with sample code. Thanks in Advance.
1
5310
by: nate axtell | last post by:
In VB .NET I load the contents of an Excel or comma seperated values file into a dataGrid (via a datatable). One of the columns has a comma in the name of the column. So for the comma separated values files I put double quotes are the column name. What I see is that the name ends up getting displayed correctly in the DataGrid column, "Class (1,2,3)". When I click on the column to sort I see the following error: "Additional information:...
2
1191
by: Starbuck | last post by:
Hi Is there anyway of capturing when the users adjusts the width of a datagrid column so the new column width can be stored. Thanks in advance
1
2062
by: Veeves | last post by:
I would like to change the width of a datagrid column at run time. I have noticed when creating a datagrid, if the header text is shorter than the data in the column, then the column width set by the framework is only wide enough to accomodate the data. The data is packed so closly together it is hard to read. I have tried changing this in the dg_itemdatabound event but ran into a problem. The e.Item.Cells(1).Width property is in...
4
2918
by: gane | last post by:
Hi, I am creating datagrid bound column dynamically and need to check if a datagrid column already exists?Is there a way to check this? thanks gane
0
1339
by: ashinamdev | last post by:
Hi I have a probelm I am using the datagrid control in my asp.net web page. I want to resize the datagrid column at runtime. User can be able to resize the column width according to his requirment at run time. Pls solve this problem. Ashish
0
8999
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
8836
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,...
0
9575
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...
0
9394
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 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...
1
9338
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
8260
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
6080
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
4712
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
3322
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

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.