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

A hyperlinked Column in GridView with captured ID

In an asp.net 2.0 GridView web control, is it possible to display one
column as a hyperlink which displays a name, such as item_name from a
db table, but capures the item_id when clicked?
If yes, then how?

May 2 '06 #1
7 1658
Go to the Columns property in design view with the grid and bring up the
Collection dialog. Click the Help button to learn about the various settings
for the Hyperlink column. It has just what you are looking for

Jeff
"coosa" <co*****@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
In an asp.net 2.0 GridView web control, is it possible to display one
column as a hyperlink which displays a name, such as item_name from a
db table, but capures the item_id when clicked?
If yes, then how?

May 2 '06 #2
I did actually; as a sample:
<asp:HyperLinkField DataNavigateUrlFields="COMPANY_ID"
DataNavigateUrlFormatString="~/Company/Page.aspx?COMPANY_ID={0}"
DataTextField="COMPANY_ID" DataTextFormatString="Info"
HeaderText="Company Info" Text="Details" />
is nested inside <columns> in the Gridview.
The only displayed item for this column are always hyperlinked "Info"
in the DataTextFormatString property.
So what i want semantically is to display the actual company name as a
hyperlink. I have tried to replace for instance
DataNavigateUrlFields="COMPANY_NAME" with
DataNavigateUrlFields="COMPANY_ID", but it had no effect. When i remove
DataTextFormatString="Info", then the company_id is displayed instead
as a hyperlink.

May 2 '06 #3
Not sure why you are showing the source code. I simply use the Collection
dialog, and it works. You are not reading the help closely enough. I JUST
went though this myself at work here this morning. They mention how one
setting over rides the others. You want DataTextField (what displays) as
Company Name, and DataURLField (used in the URL) as Company ID

Jeff

"coosa" <co*****@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
I did actually; as a sample:
<asp:HyperLinkField DataNavigateUrlFields="COMPANY_ID"
DataNavigateUrlFormatString="~/Company/Page.aspx?COMPANY_ID={0}"
DataTextField="COMPANY_ID" DataTextFormatString="Info"
HeaderText="Company Info" Text="Details" />
is nested inside <columns> in the Gridview.
The only displayed item for this column are always hyperlinked "Info"
in the DataTextFormatString property.
So what i want semantically is to display the actual company name as a
hyperlink. I have tried to replace for instance
DataNavigateUrlFields="COMPANY_NAME" with
DataNavigateUrlFields="COMPANY_ID", but it had no effect. When i remove
DataTextFormatString="Info", then the company_id is displayed instead
as a hyperlink.

May 2 '06 #4
And where is that help exactly located?
I followed the dialog in the design view -> Collection but there is no
help.
Can you at least specify WHICH property is responsible to display the
CompanyName and which property is responsible to capture the CompanyId?

Best regards

May 2 '06 #5
I just did!

In the dialog, Company Name would be Text Field, and Company ID would be URL
Field.

I'm using VS 2003

There is a Help button next to the Ok and Cancel buttons in the
Columns/Collection property dialog box

Jeff
"coosa" <co*****@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
And where is that help exactly located?
I followed the dialog in the design view -> Collection but there is no
help.
Can you at least specify WHICH property is responsible to display the
CompanyName and which property is responsible to capture the CompanyId?

Best regards

May 2 '06 #6
Thanks alot. It worked now and it was that simple!!
But just for the record, there is no helo beside the OK button in VS
2005 dialog box of the collection

May 2 '06 #7
F1?

"coosa" <co*****@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Thanks alot. It worked now and it was that simple!!
But just for the record, there is no helo beside the OK button in VS
2005 dialog box of the collection

May 2 '06 #8

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

Similar topics

7
by: Frank | last post by:
I have a navigation bar that is included in a series of pages throughout the site, using the <!-- #include file=""--> method. The bar has a black background, and I'd like the hyperlinked text on...
4
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. ...
1
by: James Rosewell | last post by:
I'm getting an error in the following scenario. - A GridView control is bound to an SQLDataSource. - The user selects a column for sorting. - Some time later in code the column used for sorting...
5
by: Steve Bugden | last post by:
Hi, I would like to set the column widths in the ASP.NET GridView control at runtime I have tried the following: http://msdn2.microsoft.com/en-us/library/ms178296.aspx Which uses the...
2
by: ianstirkcv | last post by:
Hi, Does anyone have an ASP 2.0 code sample that shows how to bind a one-dimensional array to a GridView, such that the rows are shown as hyperlinks? Thanks Ian
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
4
by: bryan | last post by:
Hi all, I am working on a .net 2.0 web app. On page load I display a gridview with a drop down list (Employees), when the user selects from the drop down list, the grid view is filled with...
1
by: noor1234 | last post by:
Hi, My gridview should have columns containing both hyperlinked and non hyperlinked cells in the same column. Example - Say there are 4 rows and 4 columns in my grid, and the 3rd column should...
3
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a GridView with a checkbox column in it called FromInsight, however this is not bound to the dataset, its value is based on another column from the dataset called sourceid For each...
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...

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.