Wednesday, September 10, 2008

Fileupload in edit template of Gridview

Code Behind File:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(GridView1.EditIndex == -1) return;
FileUpload fileUpLoad = GridView1.Rows[GridView1.EditIndex].FindControl("FileUpload1") as FileUpload;
string fileName = fileUpLoad.FileName;
string fullPath = Path.GetFullPath(fileName);
fileUpLoad.SaveAs(fullPath);
}

1 Comments:

Ben Penafiel said...

That's not work for me... File Upload always returns null....