I have a page that allows the user to select various options from drop down lists. Below this is a gridview recording the details that have been submitted previously. So when the user hits submit their data is stored in a database and the gridview is rebinded to display this data. I have 3 labels that display the number of items, the total time spent and the total cost. But when the submit button is selected the labels aren't being updated straight away. The gridview updates automatically but for the labels if you refresh the page it then updates. Any why this can be updated automatically like the gridview?
lblref.Text = Session["SessRef"].ToString();
try
{
//create and insert a new record
Activity act = new Activity();
act.ActivityAppRef = Session["SessRef"].ToString();
act.ActivityCreatedBy = HttpContext.Current.User.Identity.Name;
act.ActivityCreatedDate = DateTime.Now;
act.ActivityProcess = ddlProcess.SelectedValue;
act.ActivityAct = ddlActivity.SelectedValue;
act.ActivityGrade = ddlGrade.SelectedValue;
if (ddlTime.SelectedValue != "-1")
{
act.ActivityTime = Convert.ToInt32(ddlTime.SelectedValue);
}
else
{
Int32 Hours = 0;
if (txtTime.Text != String.Empty)
{
Hours = Convert.ToInt32(txtTime.Text);
}
Int32 Mins = Convert.ToInt32(ddlMin.SelectedValue);
Int32 Time = (Hours * 60) + Mins;
act.ActivityTime = Time;
}
//insert record
ActivityManager.InsertActivity(act);
//rebind gridvidew to show new record
gvActHistory.DataBind();
//display success message and set the values of the form back to default.
ddlProcess.SelectedValue = "0";
//ddlActivity.SelectedValue = "0"; doesn't get reset as this is dependent on value of ddlProcess
ddlGrade.SelectedValue = "0";
ddlTime.SelectedValue = "0";
txtTime.Text = String.Empty;
ddlTime.Visible = true;