这是我的问题。我正在动态添加fileuploadfields并将每个fileupload字段添加到这样的集合中
static List<FileUploadField> fuploadcollection = new List<FileUploadField>();
,到目前为止一直很好。但是当我在fileuploadfield中上传图像时,我得到了空文件上载字段。但是当我通过断点观看它时,似乎填充了“fuploadcollection”集合。
这是我的代码;
addfileupload function;
public partial class UserControl1 : System.Web.UI.UserControl
{
static int? _currentflag = 0;
static List<FileUploadField> fuploadcollection = new List<FileUploadField>();
........
........
.........
protected void addImages_Click(object sender, DirectEventArgs e)
{
int? nn = null;
X.Msg.Alert("hello", "hello").Show();
_currentflag = (!string.IsNullOrEmpty(txtcurrentflag.Text)) ? Convert.ToInt32(txtcurrentflag.Text) : nn;
FileUploadField fileUploadField = new FileUploadField()
{
ID = "FileUploadField" + _currentflag,
Width = 280,
Icon = Icon.Add,
ClientIDMode = ClientIDMode.Static,
Text = "Göz at",
FieldLabel = "Resim-" + _currentflag,
Flex = 1,
ButtonText="resim seç"
};
fileUploadField.AddTo(this.pnlResim, true);
if (string.IsNullOrEmpty(txtcurrentflag.Text) || txtcurrentflag.Text == "0")
{
fuploadcollection.Clear();
}
fuploadcollection.Add(fileUploadField);
_currentflag++;
txtcurrentflag.Text = _currentflag.ToString();
}
这是给出错误的这部分(coulnt输入if语句) *但似乎fuploadcollection已填满(例如,它显示的数量超过1)
foreach (var item in fuploadcollection)
{
if (item.HasFile)
{
string resimadi = UploadImage.UploadImages(item);
答案 0 :(得分:2)