Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataNavigateUrlFormatString Question

Posted on 2009-04-02
2
Medium Priority
?
276 Views
Last Modified: 2012-08-13
I am using Visual Studio 2003 and using a datagrid to display and link to files in a certain folder. Originally, the files were all pdf but now, I need to link to other types of files.
The files exist in a virtual directory on the intranet server.
I list the files in the datagrid without the file extension but I will need the extension for the hyperlink in the datagrid.
I'm attaching the code that gets the files into an array without the file extension.
I set up the variable "fn" to hold the filename with the extension but I'm not exactly sure how to get it.
And then I need to reference it in the datagrid:
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataNavigateUrlFormatString="http://myintranet.com/p1/csr/" ??? DataTextField="Name" Target="_blank">
The ??? is where I need help
I hope this makes sense.
Thanks!
Dim dirInfo as New DirectoryInfo(Server.MapPath("/p1/csr"))		
Dim arrFileInfo  As Array
Dim filesInfo   As FileInfo
Dim filesTable   As New DataTable
Dim drFiles    As DataRow
Dim dvFiles   As DataView
Dim ofn,ext As String
Dim charCt as Integer
Dim fn as String
				
filesTable.Columns.Add("Name", Type.GetType("System.String"))
filesTable.Columns.Add("LastWriteTime", Type.GetType("System.DateTime"))
		
' Get File Info
arrFileInfo = dirInfo.GetFiles
For Each filesInfo In arrFileInfo
  drFiles = filesTable.NewRow()
  drFiles("Name") = System.IO.Path.GetFileNameWithoutExtension(filesInfo.Name)
  drFiles("LastWriteTime") = filesInfo.LastWriteTime					
  filesTable.Rows.Add(drFiles)
Next filesInfo
				
dvFiles = filesTable.DefaultView
dvFiles.Sort = "LastWriteTime DESC"
 
dg1.DataSource = dvFiles
dg1.DataBind()

Open in new window

0
Comment
Question by:lakhi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 2000 total points
ID: 24057665
Hi lakhi,
You can define another column to store the exact file name. Then, bind this datafield under part of required parameter(s) inside DataNavigateUrlFormatString property.
http://geekswithblogs.net/AzamSharp/archive/2006/09/18/91514.aspx

eg:

vb
==========
filesTable.Columns.Add("FileName", Type.GetType("System.String"))'this column to store exact file name
filesTable.Columns.Add("Name", Type.GetType("System.String"))
....

  drFiles = filesTable.NewRow()
  drFiles("FileName") = filesInfo.Name
  drFiles("Name") = System.IO.Path.GetFileNameWithoutExtension(filesInfo.Name)
  ...

aspx
========
<asp:HyperLinkColumn DataNavigateUrlField="FileName" DataNavigateUrlFormatString="http://myintranet.com/p1/csr/{0}" DataTextField="Name" Target="_blank">

0
 

Author Comment

by:lakhi
ID: 24061487
Perfect! That's just what I needed. Thanks!!!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question