I have an attachment column that, in edit mode, allow to upload and save attachment in a folder named "Allegati".
With this snippet (thanks to Princy for it), when a file is uploaded a link is generated and it is visible inside the record when it is in edit mode. See picture attached.
The above feature works very well and I am happy of the result I got thanks to the help of this forum members.
Now what I would like to achieve is to show for each record only the links of the uploaded files relevant that particular record.
I mean If I load an attachment named "Mickey Mouse" from record A, and an attachment named "Donald duck" from record B, when I open record A I would like to see only the link to Mickey Mouse and when I open record B I would like to see only the link to Donald Duck.
Like in this forum, each thread shows links to the own attachments.
How can I achieve that?
<
telerik:GridAttachmentColumn
FileName
=
"attachment"
FilterControlAltText
=
"Filter columnAllegati column"
HeaderText
=
"Allegati"
UniqueName
=
"columnAllegati"
Visible
=
"False"
>
</
telerik:GridAttachmentColumn
>
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
//Generate links of attachments inside folder "Allegati" visible when in edit mode
if (e.Item is GridEditableItem && e.Item.IsInEditMode)// Check if the Grid is in EditMode
{
GridEditableItem edit = (GridEditableItem)e.Item;
DirectoryInfo dir = new DirectoryInfo(@"C:\Users\Pink\Documents\Visual Studio 2012\Projects\ManagDoc_Framework\Test1_managDoc\Test1_managDoc\Allegati");// path of the target folder where your files are stored
DirectoryInfo[] subDirs = dir.GetDirectories();
FileInfo[] files = dir.GetFiles(); //Getting the files inside the Directory
foreach (FileInfo fi in files) //To loop through all files for setting each file as HyperLink
{
HyperLink lktest = new HyperLink(); //Add HyperLink Column
lktest.ID = "lnk" + Guid.NewGuid(); //Setting Unique IDs
lktest.Text = fi.Name.ToString(); //Get the File name
lktest.NavigateUrl = "#";
lktest.Attributes.Add("Onclick", "ViewCheck('" + fi.Name + "')"); // Calling the JS event
//Adding the HyperLink to EditForm
edit["columnAllegati"].Controls.Add(lktest);
edit["columnAllegati"].Controls.Add(new LiteralControl("<
br
>"));
}
}
}
Now what I would like to achieve is to show for each record only the links of the uploaded files relevant that particular record.
I mean If I load an attachment named "Mickey Mouse" from record A, and an attachment named "Donald duck" from record B, when I open record A I would like to see only the link to Mickey Mouse and when I open record B I would like to see only the link to Donald Duck.
Like in this forum, each thread shows links to the own attachments.
How can I achieve that?