|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
April 16th, 2006, 11:19 PM
|
Registered User
|
|
Join Date: Feb 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hyper link to gridview
Hi all,
I want to give hyper link to column content which is shown on gridview . As i am accessing data from database and dislaying on gridview. One column is contening information of "path for stored file on disk" . I want to give hyperlink to this content on gird view.
So that when user click that link, file should get downloaded.
is there any easiest method to do same?
Regards,
Samir Katore
samir
|
May 2nd, 2006, 06:18 PM
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Samir,
I used this in a DataGrid awhile back and it worked fine.
This assumes the field in the database being referenced contains the path to the file as a string.
Paul O
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<center>
<a href="<%# DataBinder.Eval(Container.DataItem,"FilePath") %>" target="_blank">
<img src="i/View.bmp" border="0">
</a>
</center>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="File_Name_Orig" HeaderText="FileName" />
</Columns>
|
May 3rd, 2006, 01:52 AM
|
Registered User
|
|
Join Date: Feb 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi polofson,
I have plced hyperlink field on Grid view. But problem is that as open the page my database field contain path to file like "c:\samir.txt" which is get retrived from database to grid view.
But as i have placed hyperlink on grid view, hyper link is taking path like "Root directory\c:\samir.text".
Which is not valid path so hyperlink is disabled on gridview and only static text is appering on grid view. So now i want remove root directory path and wnna keep only database field path as ref to hyperlink.
Here is code what i have Done:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="AUNumber" DataSourceID="SqlDataSource1" SelectedIndex="1" Width="1124px">
<Columns>
<asp:BoundField DataField="AUNumber" HeaderText="AUNumber" InsertVisible="False"
ReadOnly="True" SortExpression="AUNumber" />
<asp:BoundField DataField="Project" HeaderText="Project" SortExpression="Project" />
<asp:BoundField DataField="ConPerson" HeaderText="ConPerson" SortExpression="ConPerson" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="TelNo_MobileNo" HeaderText="TelNo_MobileNo" SortExpression="TelNo_MobileNo" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="ProjEngg" HeaderText="ProjEngg" SortExpression="ProjEngg" />
<asp:BoundField DataField="BackupOnServer" HeaderText="BackupOnServer" SortExpression="BackupOnServer" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks" SortExpression="Remarks" />
<asp:BoundField DataField="BackUpPath" HeaderText="BackUpPath" SortExpression="BackUpPath" />
<asp:HyperLinkField DataNavigateUrlFields ="BackUpPath" HeaderText="Back up Path" DataTextField ="BackUpPath" DataNavigateUrlFormatString="{0}" >
<ItemStyle ForeColor="#FFC0FF" />
</asp:HyperLinkField>
</Columns>
</asp:GridView>
Where "BackUpPath" is databse field which contains: "c:\samir.txt"
So my aim is when user click on this column samir.txt should get opened.
samir
|
May 3rd, 2006, 09:11 AM
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Samir,
Here's some more detail. In my web app I have created a sub folder where I store all my files I link to. I called the folder 'f' for files. In the database I store the link to the files in this format ./f/log.txt in a field called 'filename.' You need the dot before the slash and the file is log.txt.
Then in the DataGrid, use:
<a type="file" href="<%# DataBinder.Eval(Container.DataItem,"filename") %>" target="_blank">clickhere</a>
When you run the application and hover over the link the status bar should read, "http://localhost/webappname/f/log.txt."
Sincerely,
Paul O
|
May 4th, 2006, 12:45 AM
|
Registered User
|
|
Join Date: Feb 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dear polofson,
Thanx for your reply but i have to keep my folder at root folder of web, and it is not possible to access the folder out side root folder. like on other drive or folder on local machine.
If you find some thing relating to this i will very happy to receive the same.
samir
|
August 20th, 2006, 10:19 PM
|
Registered User
|
|
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Samir,
Have you found the solution ? I've got the same problem as well where I can not remote the root path.
If you found the solution, please post it in here ...
Thank you
|
August 20th, 2006, 10:38 PM
|
Registered User
|
|
Join Date: Feb 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi!
Uptill now i won get any solution for the same.
samir
|
|
|