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

Grid to Open all files in Folder (or just folder)

2 Answers 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 04 Apr 2014, 01:42 PM
NUTSHELL
I want top either open all the files in a folder from the radGrid.  If that cannot be done, then I'd like to open the folder.

DETAIL
I want to add a column to the grid (hyperlink column?) that, wehn clicked, will open all of the PDF files in that folder.  There is an unknown amount in that folder, but it's likely no more than 4.  There could also be no files in that folder and in some cases, the folder may not exist-- the located is a concatenated value from three other fields.

If all the files cannot be opened, then perhaps we can settle for opening the folder-- again, provided it does exist.

I am programming in MS Visual Studio 2012.
I am using Telerik UI for ASP.NET AJAX, v.2014.1.225.45

2 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 09 Apr 2014, 07:49 AM
Hello Rick,

RadGrid does not have a built-in functionality that could allow you to accomplish such behavior. However, what I could suggest is that you use a GridTemplateColumn for an example and place a LinkButton in that column. Then you could set the CommandName property of the LinkButton control and to handle that command in the server-side OnItemCommand event of the grid.

The server-side OnItemDataBound event could be handled for setting the Text property of the LinkButton. Following is a simple example of that approach:
<telerik:RadGrid  runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
    OnItemDataBound="RadGrid1_ItemDataBound" OnItemCommand="RadGrid1_ItemCommand">
    <MasterTableView AutoGenerateColumns="false">
        <Columns>
            <telerik:GridBoundColumn DataField="ID"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="LinkColumn">
                <ItemTemplate>
                    <asp:LinkButton runat="server" ID="LinkButton1" CommandName="OpenPdfFiles"></asp:LinkButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
And the code-behind:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        DataRow row = (item.DataItem as DataRowView).Row;
        LinkButton linkButton = item["LinkColumn"].FindControl("LinkButton1") as LinkButton;
        linkButton.Text = row["Field1"].ToString() + row["Field2"].ToString() + row["Field3"].ToString();
        linkButton.PostBackUrl = "#";
    }
}
 
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "OpenPdfFiles")
    {
        LinkButton linkButton = e.CommandSource as LinkButton;
   //your custom logic for opening the PDF files
    }
}

Please note that you will have to come up with your own logic form opening the PDF files from the folder.


Regards,
Konstantin Dikov
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 10 Apr 2014, 04:55 PM
Thank you.

I ended up just opening the folder location

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
Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Rick
Top achievements
Rank 1
Share this question
or