473,326 Members | 2,012 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,326 software developers and data experts.

How do I display a field in grid contents as a hyperlik


Fellow developers,
I need to find out how to display one of the fields listed in my
gridview as a hyperlink. The field displays the physical file path of
for example a pdf file. I want my users to be able to click on the
field(filepath) and the browser must open the file it points to.
I am using VS2005, setup in web developer mode. The database behind it
is MS-SQL 2005
thanks in advance!

MartinCoetsee
--
Martin.Coetsee
------------------------------------------------------------------------
Martin.Coetsee's Profile: http://www.hightechtalks.com/m438
View this thread: http://www.hightechtalks.com/t426806

Dec 14 '06 #1
1 1326
On Thu, 14 Dec 2006 12:45:48 -0600, Martin.Coetsee wrote:
Fellow developers,
I need to find out how to display one of the fields listed in my
gridview as a hyperlink. The field displays the physical file path of
for example a pdf file. I want my users to be able to click on the
field(filepath) and the browser must open the file it points to.
I am using VS2005, setup in web developer mode. The database behind it
is MS-SQL 2005
thanks in advance!

MartinCoetsee
Hi Martin

The gridView has an "onRowCommand" that you can assign a delegate to. The
column could be a button whose "text" is the name of the pdf and whose
commandName is say "pdfFinder". Below is a loose example cobbled together
from another app (code is not tested!!). I build my columns dynamically in
the other app.

HTH
Mark

e.g.
<asp:GridView ID="pdfGridView"
runat="server"
Style="z-index: 100; width: 650"
onRowCommand="pdfRowCommand"
BorderStyle="None"
GridLines="None"
ShowHeader="false"
RowStyle-VerticalAlign="Top"
RowStyle-Height="17px" >
<Columns>
<asp:TemplateField HeaderText="PDF File">
<ItemTemplate>
<asp:Button
ID="pdfButton"
runat="server"
CommandName="pdfFinder"
CommandArgument='<%# Eval("pdfFile") %>'
Text='<%# Eval("pdfFile") %/>
</ItemTemplate>
</Columns>
</asp:GridView>

protected void pdfRowCommand(Object src, GridViewCommandEventArgs e)
{
string commandIs = e.CommandName;
if (commandIs == "pdfFinder")
{
// get the row index stored in the CommandArgument property
int index = Convert.ToInt32(e.CommandArgument);
// get the GridViewRow where the command is raised
GridViewRow selectedRow = ((GridView)e.CommandSource).Rows[index];
// get the pdfName
string pdfName = selectedRow.Cells[0].Text;
// Show the pdf
Session["PDFFileName"] = pdfName;
Server.Transfer("showPdf.aspx");
}
Dec 14 '06 #2

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

Similar topics

2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
1
by: Beowulf | last post by:
I'm having some difficulty and I can't for the life of me figure out why. I have a main report, rptMain, that contains a report header (displays the AppTitle), 3 group headers (one is a header...
2
by: Ken Allen | last post by:
I have an application that invokes a remote process that returns a (possibly empty) DataSet as the result, and the contents of this are then displayed in a DataGrid by setting the data source to...
0
by: Stefano Coluccia | last post by:
Hi, I'm using compact framework for pocket Pc and I should change the display values of a column in a grid, so I've a xml file where there is a field where are saved the follow value 1,2,3 but I...
6
by: Jesse Aufiero | last post by:
I was wondering if anyone knows how to get a datagrid to size as the browser is resized such that the datagrid's borders would appear anchored to the browser edges. The datagrid should have a...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
0
by: bluesyt | last post by:
Greetings, I have never used grids before and I'm relatively new to VB. I am using VB6 and ADO to pull data from an SQL database. Everything works and I can get the data into the grid but when...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...

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.