如何制作功能下载文件.pdf ,.基于复选框选择的jpg等?
问题描述:
你能帮我,如何在gridview中制作功能下载文件库选中复选框?
如果是选择一个复选框,我按下按钮下载所以我会下载选中一个文件库复选框,如果我选择两个复选框并按下按钮下载,我将下载两个文件库复选框。
请帮帮我,谢谢你。
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.
答
您可以执行以下代码之类的操作。如果你有很多可以通过Text或Tag属性轻松区分的复选框,它会很好用。
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.
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.