file upload posted file not working in formview

S

sandya

here is the code i tried

string ss;
//FileUpload FileUpload1 = new FileUpload();
Label Labeltxt = new Label();
//FileUpload1 = FormView1.FindControl("FileUpLoad1") as
FileUpload;
FileUpload FileUpload1 =
(FileUpload)FormView1.Row.FindControl("UploadMB");
ss = FileUpload1.ID.ToString();
Labeltxt = FormView1.FindControl("lblfileupload") as Label;

if (FileUpload1.HasFile)
{
int id = objmsg.GetMessageBoardLastID();
string fName = "MSG" + id +
Path.GetExtension(FileUpload1.PostedFile.FileName);
string fPath = Server.MapPath(Request.ApplicationPath) +
"\\MessageBoard\\" + fName;
FileUpload1.SaveAs(fPath);
Labeltxt.Text = "Received " + FileUpload1.FileName;
}
else
{
Labeltxt.Text = "No uploaded file";

}



but the fileupload1.hasfile shows false even if i selected file.why
this come.pls give a solution for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top