這裏是我的疑難問題。我動態地添加fileuploadfields並添加每個文件上傳字段集合像這樣文件上傳領域得到空值
static List<FileUploadField> fuploadcollection = new List<FileUploadField>();
,當我特林到目前爲止好。但上傳圖片到fileuploadfield裏面,我得到了空的fileupload字段。但是當我通過斷點觀察它時,它似乎填充了「fuploadcollection」集合。
這裏是我的代碼;
addfileupload功能;
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填充(forexample它的統計顯示更多的則1)
foreach (var item in fuploadcollection)
{
if (item.HasFile)
{
string resimadi = UploadImage.UploadImages(item);
的就是你得到的異常? – Damith
也不例外只是文件上傳字段爲空,你給txtcurrentflag文本框中 – sakir
什麼樣的價值? – Damith