This is a migrated thread and some comments may be shown as answers.

Display Network Folder

3 Answers 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 12 May 2014, 03:02 PM
I am looking for a solution that will allow me to click a button or a hyperlink within a row and open a folder on our network.  The location to be opened is stored in the record source for that grid.

I have tried a couple of things, both of which failed.  Granted, the solution I have are either my own creation or a hybrid of my code and assistance from the forums.


FAILED SOLUTION #1
This column contains a button that opens the folder.  This does work locally, but does not work when published to our web folder.
<telerik:GridButtonColumn FilterControlAltText="Filter Files column" CommandName="ShowFiles"  UniqueName="Files" ButtonType="PushButton" HeaderText="Files" Exportable="False" Text="Display">
</telerik:GridButtonColumn>

Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
    Dim value As String
 
    If e.CommandName = "ShowFiles" Then
        Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
 
        value = dataItm("Location").Text & "\03 Submitted\"
  
        Process.Start("explorer.exe", value)
  
    End If
 
End Sub


FAILED SOLUTION #2
This does nothing but reload the page. 
<telerik:GridTemplateColumn UniqueName="LinkColumn">
    <ItemTemplate>
        <asp:LinkButton runat="server" ID="LinkButton1" CommandName="ShowFiles"></asp:LinkButton>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Private Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
 
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
        Dim row As DataRow = TryCast(item.DataItem, DataRowView).Row
        Dim linkButton As LinkButton = TryCast(item("Location").FindControl("LinkButton1"), LinkButton)
        linkButton.Text = "Location"
        linkButton.PostBackUrl = "#"
    End If
 
End Sub

  
Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
    Dim value As String
 
    If e.CommandName = "ShowFiles" Then
 
        Dim linkButton As LinkButton = TryCast(e.CommandSource, LinkButton)
        Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
        value = dataItm("Location").Text & "\03 Submitted\"
 
        Process.Start("explorer.exe", value)
 
    End If
 
End Sub

3 Answers, 1 is accepted

Sort by
0
Rick
Top achievements
Rank 1
answered on 12 May 2014, 03:08 PM
FAILED SOLUTION #3

I changed the link format as follows.  This only reloads the page, but again, it works locally.
If e.CommandName = "ShowFiles" Then
 
    Dim linkButton As LinkButton = TryCast(e.CommandSource, LinkButton)
    Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
    value = dataItm("Location").Text & "\03 Submitted\"
 
    Process.Start("explorer.exe", "file:///k|/Proposal/2014")
 
End If
0
Maria Ilieva
Telerik team
answered on 15 May 2014, 11:05 AM
Hi Rick,

Could you please verify if the same approaches for opening the local folder work out of the RadGrid  control?
Generally the mentioned issue is not related to the RadControls but is most probably environment issue as some of the approaches work locally and not when the site is published.
You should revise the environment configurations and the specific folder permissions and isolate the issue on your end.

You could see discussions for similar issues below:
http://stackoverflow.com/questions/18240909/accessing-a-network-file-share-with-c-sharp
http://www.c-sharpcorner.com/uploadfile/sri85kanth/accessing-network-drive-in-C-Sharp/
http://social.msdn.microsoft.com/Forums/vstudio/en-US/0d2d20fa-a0c0-4df0-afb4-08cd78db0481/c-list-files-and-directories-in-a-network-folder?forum=netfxbcl
http://social.msdn.microsoft.com/Forums/vstudio/en-US/ce864f19-25c1-4601-a1ff-6019c703ccdb/opening-a-folder-from-c

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rick
Top achievements
Rank 1
answered on 04 Jun 2014, 01:19 PM
Thanks for your reply.  We eventually got this working with IE and also Chrome with a plug-in.  Nothing special...  I always test in Chrome and never checked IE to see if that would work.

We may already have permissions configured on the folder to allow this.

<telerik:GridTemplateColumn ColumnGroupName="DLB" UniqueName="Location"  Display="True" HeaderText="Files" >
    <ItemTemplate>
        <a href="<%# Eval("Location")%>" target="_blank">Open folder</a>
    </ItemTemplate>
</telerik:GridTemplateColumn>
Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Rick
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or