M
Michael Kellogg
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.";
ShowAsError(Message);
}
else
{
GridView1.DataSourceID = "DropsInJob"; // connecting the
DataSource object and the grid will retrieve the data and bind it
ShowAsText(Message);
if (GridView1.Rows.Count > 0)
{
Message.Text = "Found the following drops for job " +
txtJobNumber.Text +
". Drops are sorted by file creation date/time:";
}
else
{
Message.Text = "Could not find any drops for job " +
txtJobNumber.Text + ".";
ShowAsError(Message);
}
}
}
"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.
Thanks,
Michael
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.";
ShowAsError(Message);
}
else
{
GridView1.DataSourceID = "DropsInJob"; // connecting the
DataSource object and the grid will retrieve the data and bind it
ShowAsText(Message);
if (GridView1.Rows.Count > 0)
{
Message.Text = "Found the following drops for job " +
txtJobNumber.Text +
". Drops are sorted by file creation date/time:";
}
else
{
Message.Text = "Could not find any drops for job " +
txtJobNumber.Text + ".";
ShowAsError(Message);
}
}
}
"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.
Thanks,
Michael