多个fileupload上传问题
页面上有5个FileUpload,FileUpload1到FileUpload5想点击按钮实现多文件上传,并保存到数据库,点击时验证下FileUpload是否有文件
protected void btnupload_Click(object sender, EventArgs e)
{
int j;
for (j = 1; j <= 5;j++ )
{
string fileup="FileUpload"+j.ToString();
upload((FileUpload)this.FindControl(fileup));//调用upload方法
}
}
protected void upload(FileUpload myFileUpload)
{
if (myFileUpload.HasFile)
{
//保存数据库
}
}
但是myFileUpload.HasFile总出错,提示未将对象引用设置到对象的实例。检查发现myFileUpload始终是NULL
这个该怎么解决,请教下