By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

Timing of updating labels and GridView after a SQLDataSource read

P: n/a
I have a problem wherein a query that updates a GridView doesn't seem to
really stay in sync with a label I have above the GridView.

I have a GridView object that I'm updating with information whenever my
user enters a job number into a textbox and hits a button. There is a
SQLDataSource object on the page that does the retrieval of the data, and
the job number parameter for its query is bound to the textbox "Text"
value. In the button handler, I'm simply saying:

protected void btnFindJob_Click(object sender, System.EventArgs e)
if (txtJobNumber.Text == "")
Message.Text = "You must enter a job number first.";
GridView1.DataSourceID = "DropsInJob"; // connecting the
DataSource object and the grid will retrieve the data and bind it
if (GridView1.Rows.Count > 0)
Message.Text = "Found the following drops for job " +
txtJobNumber.Text +
". Drops are sorted by file creation date/time:";
Message.Text = "Could not find any drops for job " +
txtJobNumber.Text + ".";
"Message" is my label. What happens is that the grid updates as it's
supposed to, but the label seems to lag a little. Let's say I run a query
on job #123 that has no entries. The grid will not show up and the label
will show "There are no drops for job 123". Then I type in a different job
number, 678, into the textbox and hit the button. The grid updates with
the retrieved data on that job, but the label still says "There are no
drops for job 678". The grid is right and the job number in the label is
right, but the text of the label is wrong. If I hit the button again right
away, the label changes to "Found these drops for job 678:", as it's
supposed to.

I'm thinking I should be updating the label text in a different place or
something; a different method, maybe during rendering? Anybody see what
I'm doing wrong, here? I'd sure appreciate some feedback.

Apr 6 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.