Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7027013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:11:33+00:00 2026-05-28T00:11:33+00:00

In my asp.net application i have a gridview control, in which i added a

  • 0

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();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:11:34+00:00Added an answer on May 28, 2026 at 12:11 am

    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…

    //If first time page is submitted and we have file in FileUpload control but not in session
            // Store the values to SEssion Object
            if (Session["FileUpload1"] == null && FileUpload1.HasFile)
    {
    Session["FileUpload1"] = FileUpload1;
    Label1.Text = FileUpload1.FileName;
    }
    // Next time submit and Session has values but FileUpload is Blank
            // Return the values from session to FileUpload
            else if (Session["FileUpload1"] != null && (! FileUpload1.HasFile))
    {
    FileUpload1 = (FileUpload) Session["FileUpload1"];
    Label1.Text = FileUpload1.FileName;
    }
    // Now there could be another sictution when Session has File but user want to change the file
            // In this case we have to change the file in session object
            else if (FileUpload1.HasFile)
    {
    Session["FileUpload1"] = FileUpload1;
    Label1.Text = FileUpload1.FileName;
    }
    

    for more info

    http://www.codeproject.com/Tips/101834/How-to-Maintain-FileUpload-Control-s-State-after-P.aspx

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have an ASP.NET application inside which i have a GridView.I have Skin file
i am having a asp.net and c#.net application and i have a page gridview.aspx
I have gridview in my asp.net 3.5 application [C#]. Which looks like this: <asp:GridView
I have developed an asp.net application that has a Gridview control. I want it
I have a GridView and want to on an ASP.NET Web Application page and
I have a Gridview control in asp.net with C#. In my application when I
I have an ASP.NET web application which uses EF4. I have a page with
I am currently developing an ASP.net c# application. I have a grid view which
i have to modify an asp.net application. The app consists of an huge gridview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.