In my asp.net application i have a gridview control, in which i added a template column with fileupload control.
And outside the gridview in the page i have a button control which performs some task.
My issue is that when i click the button, the file which i chosen via file upload control in gridview has get refreshed and the file path vanishes.
How can i stop refreshing the gridiew when i click the button.
Button is not inside the grid.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("id", typeof(string));
dt.Columns.Add(dc1);
dr = dt.NewRow();
dr[0] = "abcd";
dt.Rows.Add(dr);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
File upload control is not designed to maintain filepath on poskback.. but you can have a workaround of it.. try storing filepaths in session variables.. i know it bit clumsy but seems like the only way to do this.. one more thing you can do to lessen you effort is to create a UserControl that will manage this for you…
for more info
http://www.codeproject.com/Tips/101834/How-to-Maintain-FileUpload-Control-s-State-after-P.aspx
Regards