如何通过动态生成的文件上传控件上传文件并单击动态生成的按钮事件?
以下是我尝试的代码,但它不起作用:
void UpLdButton_Click(object sender, EventArgs e)
{
Button btnUpLD = sender as Button;
btnUpLD = (Button)this.FindControl(Form.ID).FindControl(table.ID).FindControl(row.ID).FindControl(cell.ID).FindControl(UpLdButton.ID);
fileUp = (FileUpload)this.FindControl(Form.ID).FindControl(table.ID).FindControl(row.ID).FindControl(cell.ID).FindControl(fileUp.ID);
string args = ((Button)sender).CommandArgument;
//lblTest.Text = args;
//UploadFile(fileUp);
if (fileUp.HasFile)
{
fileUp.PostedFile.SaveAs(Server.MapPath("~\\") + fileUp.FileName);
Label1.Text = "The" + fileUp.FileName + " Has been uploaded";
}
else
{
Label1.Text = "FILE not selected";
}
}
提前致谢!!!