的兩個事件是轉發器itemboungf重複超過要求?
protected void btnuplaod_Click(object sender, EventArgs e)
{
string filepath = Server.MapPath(@"~/Admin/temp/");
Session["Image"] = Request.Files;
HttpFileCollection uploadedFiles = (HttpFileCollection)Session["Image"];
lblerror.Text = string.Empty;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
lblerror.Text += "<u>File #" + (i + 1) + "</u><br>";
lblerror.Text += "File Content Type: " + userPostedFile.ContentType + "<br>";
lblerror.Text += "File Size: " + userPostedFile.ContentLength + "kb<br>";
lblerror.Text += "File Name: " + userPostedFile.FileName + "<br>";
userPostedFile.SaveAs(filepath + Path.GetFileName(userPostedFile.FileName));
lblerror.Text += "Location where saved: " + filepath + "\\" + Path.GetFileName(userPostedFile.FileName) + "<p>";
}
repimages.DataSource = filepath;
Session["repimage"] = userPostedFile.FileName;
repimages.DataBind();
}
catch (Exception Ex)
{
lblerror.Text += "Error: <br>" + Ex.Message;
}
}
}
和
protected void repimages_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
string filepath = Server.MapPath(@"~/Admin/temp/");
lblerror.Text = string.Empty;
Image img = e.Item.FindControl("postedimage") as Image;
img.ImageUrl = filepath + Session["repimage"];
}
repimages_ItemDataBound(對象發件人,RepeaterItemEventArgs E)事件被重複48次,單個圖像
其實按鈕單擊事件我是一個文件夾中存儲多個圖像和我他們想顯示給用戶點擊那個按鈕,這就是爲什麼我正在考慮這種替代方法是有任何其他方法來做到這一點。這個中繼器可以綁定該文件夾 – VJain
你必須再次綁定中繼器以反映數據更新。 repimages_ItemDataBound處理程序與它沒有任何關係,我想。 – Nanosoft
做了我想做的事情,謝謝你的幫助 – VJain