Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Can you help me, how to make function download file base selected checkbox in gridview?

If is select one checkbox and i press button download so i will download one file base checkbox selected, and if i select two checkbox and press button download, i will download two file base checkbox selected.

Help me please, thankyou.
Posted
Comments
Afzaal Ahmad Zeeshan 28-Feb-15 23:35pm    
What actually have you done until now? I believe this program can be easily created using a simple loop over checkboxes, and where condition is true (selected) you should download the image (file).

1 solution

You can do something like the code below. It works well if you have a lot of check boxes that can easily be distinguished via the Text or Tag properties.

C#
private void buttonDownload_Click(object sender, EventArgs e)
{
    foreach (Control ctrl in this.Controls) // this = the form
    {
        CheckBox chk = (ctrl as CheckBox);  // Only care about checkbox controls
        if (chk != null)
        {
            if (chk.Checked)
            {
                string text = chk.Text;     // Can be used to select download action
                // Do your stuff
            }
        }
    }
}

As I don't know what you want to download or how your check boxes look like, I cannot give a more specific solution.
 
Share this answer
 
Comments
Member 10889447 1-Mar-15 14:56pm    
I want to make function download base selected checkbox.
George Jonsson 1-Mar-15 21:02pm    
How can you download a checkbox?
And what is a 'base selected checkbox'?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900