Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a datagrid that lists files in a directory with hyperlinks to each file. I would like each hyperlink to be the filename without the extension but then I need the filename with the extension for the hyperlink.

Here is the relevant part of my code:

Sub BindData()	
  'variables defined in this part - not shown
  filesTable.Columns.Add("Name", Type.GetType("System.String"))

  ' Get File Info
   arrFileInfo = dirInfo.GetFiles("*.aspx")

   For Each filesInfo In arrFileInfo
     If filesInfo.Name <> "dr.aspx" and filesInfo.Name <> "Search.aspx" then
drFiles = filesTable.NewRow()
ofn = filesInfo.Name
charCt = Instr(ofn, ".aspx") -1
ofn = Mid(ofn, 1, charCt)
drFiles("Name") = ofn
filesTable.Rows.Add(drFiles)
     End If
  Next filesInfo

  'code for the hyperlink column in the datagrid
 <asp:HyperLinkColumn Target="_blank" 
   DataNavigateUrlField="Name" 
   DataNavigateUrlFormatString="{0}"       
   DataTextField="Name"/>

 

Thanks for any help

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...