I have a placeholder control where i have added the files from my folder. I have also binded a check box with each file How i can download the files if checkbox is clicked.

string strDir = Request.QueryString["d"] == null ? FileBrowerProperty.IntialPath : Request.QueryString["d"];

//read the directory
DirectoryInfo DirInfo = new DirectoryInfo(strDir);
//read the subdirectories inside the parent directory
DirectoryInfo[] subDirs = DirInfo.GetDirectories();
//read the files in the parent directory
FileInfo[] Files = DirInfo.GetFiles();

foreach (DirectoryInfo di in subDirs)
{
    ListItem listitem1 = new ListItem(di.FullName);
    // <a href='more.php' onclick='show_more_menu()'>More >>></a>
    //add the directory info to our table 
    LiteralControl lcFolders = new LiteralControl(@"<TR><TD style='WIDTH: 20px'><input type='checkbox' id='"
       + @di.FullName
       + "'>Directory</TD><TD style='WIDTH:350px'><a href='webform1.aspx?d=" 
       + @di.FullName + "'>" + di.Name + "</a></TD><TD style='WIDTH: 150px'>" 
       + di.CreationTime + "</TD><TD style='WIDTH: 150px'>" + di.LastWriteTime 
       + "</TD></TR>");

    PlaceHolder1.Controls.Add(lcFolders);  
}

How to download files from a placeholder control if checkbox is clicked if its not possible then plz tell me that how can i loop through the contents of the placeholder so that i can findout the checkbox and then supply the file name to download the file

use checkboxList at server side and use onSelectedIndexChanged or onTextChanged to download file...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.