Hi,
Try this if it could help ...
Example in your code behind:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Button bts = e.CommandSource as Button;
Response.Write(bts.Parent.Parent.GetType().ToString());
if (e.CommandName.ToLower() != "upload")
{
return;
}
FileUpload fu = bts.FindControl("FileUpload4") as FileUpload;
if (fu.HasFile)
{
bool upload = true;
string fleUpload = Path.GetExtension(fu.FileName.ToString());
if (fleUpload.Trim().ToLower() == ".xlsx")
{
fu.SaveAs(Server.MapPath("~/UpLoadPath/" + fu.FileName.ToString()));
string uploadedFile = (Server.MapPath("~/UpLoadPath/" + fu.FileName.ToString()));
}
else
{
upload = false;
}
if (upload)
{
}
}
else
{
}
}
You must have a Sub directory
UpLoadPath in you apps domain rather in you
project solution to copy such file, to be visible in your apps. Otherwise this could
run in your local, but when it published you may encountered file not found error...
Hope this could help...
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Regards,
Algem