Linkbutton to open Windows Explorer from Gridview

Posted by xt_20 on Stack Overflow See other posts from Stack Overflow or by xt_20
Published on 2010-06-04T06:17:41Z Indexed on 2010/06/04 6:19 UTC
Read the original article Hit count: 240

Filed under:
|
|
|
|

Hi all, I have a link in a Gridview that I want opened in Windows Explorer (or explorer.exe).

<asp:GridView  ID="GridView1"runat="server" >
   <Columns>
       <asp:TemplateField>
           <ItemTemplate>
               <asp:LinkButton ID="DeploymentLocation" runat="server" CommandName="OpenLink" 
                   Text='<%# Eval("DeploymentLocation") %>' CommandArgument='<%# Eval("DeploymentLocation") %>'  />
           </ItemTemplate>
        </asp:TemplateField>
   </Columns>

and in codebehind I have this:

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
          Process.Start("explorer.exe", "/n," + e.CommandArgument.ToString());
    }

Obviously this doesn't work as Process.Start only works if I have full permissions, etc, etc. I heard that I can use Javascript to do this, but haven't succeeded so far. Basically, what I want is the exact link that is displayed in the grid to be opened when clicked. Any help would be much appreciated!

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET