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 7459013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:55:50+00:00 2026-05-29T13:55:50+00:00

All the research I’ve done seems to indicate that if I simply call DataBind()

  • 0

All the research I’ve done seems to indicate that if I simply call DataBind() again then my GridView will get updated. This only seems to be the case if I’m debugging and stepping through my code, the GridView refreshes fine. However, if I don’t step through my code while running the app in debug mode, the btnFileImport_Click method below doesn’t refresh my GridView. Could it have anything to do with the fact that I’m updating the data the GridView uses by loading a file using an SSIS package? Below is the code behind:

namespace InternationalWires
{
    public partial class Default_Corporate : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection
        (
            ConfigurationManager.ConnectionStrings
            ["InternationalWiresConnection"].ToString()
        );
        SqlCommand cmd = null;
        SqlServerAgent sqlAgent = new SqlServerAgent();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRatesGrid();
            }
        }
        public void BindRatesGrid()
        {
            conn = new SqlConnection
            (
                ConfigurationManager.ConnectionStrings
                ["InternationalWiresConnection"].ToString()
            );
            SqlDataAdapter da = new SqlDataAdapter("spGetRates", conn);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataSet ds = new DataSet();
            da.Fill(ds);
            grdRates.DataSource = ds.Tables[0].DefaultView;
            grdRates.DataBind();
        }
        protected void btnFileImport_Click(object sender, EventArgs e)
        {
            // Get the filename and path from the user.
            // Must be in UNC format or SSIS will fail.
            string filename =
                Path.GetFullPath(fileSelect.PostedFile.FileName);
            // Update the settings table to the value from above.
            try
            {
                conn = new SqlConnection
                (
                    ConfigurationManager.ConnectionStrings
                    ["InternationalWiresConnection"].ToString()
                );
                cmd = new SqlCommand
                (
                    "UPDATE Settings SET settingValue = '" + filename +
                    "' WHERE settingName = 'SSISRatesImportFile'", conn
                );
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                // To do: handle exceptions.
            }
            finally 
            {
                if (conn != null) conn.Dispose();
                if (cmd != null) cmd.Dispose();
            }
            // Set the name of the SSIS package to run.
            sqlAgent.SSISName = ConfigurationManager
                .AppSettings["ratesImportPackage"].ToString();
            // Start the job.
            sqlAgent.SQL_SSISPackage();
            // Do nothing while waiting for job to finish.
            while (sqlAgent.SQL_IsJobRunning()) { }
            if (sqlAgent.SQL_JobSucceeded())
            { 
                lblStatus.Text = "Import Succeeded";
                BindRatesGrid();
            }
            else
            { 
                lblStatus.Text =
                "Import Failed. " + 
                "Please contact IT for failure details on SSIS import package."; 
            }

        }
    }
}

  • 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-29T13:55:51+00:00Added an answer on May 29, 2026 at 1:55 pm

    After much banging of my head on the desk, I finally stumbled across the answer in a roundabout way.

    My SQL_IsJobRunning and SQL_JobSucceeded methods use sp_help_job in SQL to figure out whether or not the job is still running, and whether or not it succeeded. I was working on the success/error messages to display in my label and when I was getting the wrong ones I realized that the ‘current_execution_status’ was showing the job was done, but the ‘last_run_outcome’ had not yet been updated by the time my code was looking at the value. So I put a pause (Thread.Sleep(4000)) in between the two methods to give the database a chance to log the last_run_outcome before I checked it.

    This solved my label error message issue, and had the pleasant side effect of also solving my GridView problem. With the pause in place the GridView also updates successfully. There must have been something happening too fast for the GridView to update properly. I just wish I knew what. Perhaps the BindRatesGrid() method was being run before he data was committed in the database.

    // Do nothing while waiting for job to finish.
    while (sqlAgent.SQL_IsJobRunning()) {}
    Thread.Sleep(4000);
    if (sqlAgent.SQL_JobSucceeded())
    { 
        lblStatus.Text = "Import Succeeded";
        BindRatesGrid();
    }
    else
    { 
        lblStatus.Text = "Import Failed. " +
        "Please contact IT for failure details on SSIS import package."; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All my research so far seems to indicate it is not possible to do
First of all, I've done my research and I did find a bunch of
All my research so far suggests this can't be done, but I'm hoping someone
I want get all page content of website Examp : http://academic.research.microsoft.com/Author/1789765/hoang-kiem?query=hoang%20kiem I used this
I've done some research into this but not sure I understand all the pieces
All my research shows that there's no real usage for the @private directive -
This should be an easy one, but through all the research I've done on
Sorry this is a basic question, but all my research just barely missed answering
I made a research and all posts here are very blury regarding this issue.
I did some research but all I could find was syncing data core with

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.