Hello,
In an effort to get some kind of 'busy' indicator while a stored procedure executes and prepares data I have implemented the AJAX updatPanel and UpdateProgress. After some testing I have it 'kind of' working but my datagrid is not refreshing. Here is my code... please advise:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:ImageButton ID="ImageButton3" runat="server" Height="46px"
ImageUrl="~/images/loaddataArrowDown.jpg" onclick="ImageButton3_Click"
ToolTip="After selected race, arena and gender click here to load the data."
Width="46px" /></ContentTemplate></asp:UpdatePanel><asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server"><ProgressTemplate> <img src="images/progress.gif" width="46" height="46" /></ProgressTemplate></asp:UpdateProgress>
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
// this does not work either : ImageButton3.Visible = false;
string iMyReturnValue = null;
using (SqlConnection connection = new SqlConnection("Data Source=mydb;Initial Catalog=dba;Persist Security Info=True;User ID=DBAreader;Password=r0ll1e0lie"))
{
SqlCommand command = new SqlCommand("exec ShowStats @Racer, @CutoffDate, @Gender, @BatchStamp OUTPUT", connection);
command.Parameters.Add("@Racer", System.Data.SqlDbType.VarChar);
command.Parameters.Add("@CutoffDate", System.Data.SqlDbType.VarChar);
command.Parameters.Add("@Gender", System.Data.SqlDbType.VarChar);
command.Parameters.Add("@BatchStamp", System.Data.SqlDbType.VarChar);
command.Parameters["@Racer"].Value = DropDownList1.SelectedValue.ToString();
command.Parameters["@CutoffDate"].Value = TextBox3.Text;
command.Parameters["@Gender"].Value = DropDownList4.SelectedValue.ToString();
command.Parameters["@BatchStamp"].Value = "Nothing";
command.Connection.Open();
command.CommandTimeout = 0;
iMyReturnValue = Convert.ToString(command.ExecuteScalar());
command.Connection.Close();
Session["BatchStamp"] = iMyReturnValue;
}
GridView1.Enabled = true;
GridView1.DataBind();
// this does not work - ImageButton3.Visible = true;
}
Please advise where I should place the databind something that will initiate showing the new dataset data in the datagrid?
Also I would like the actual button to be hidden while the data is loading. In the code I pasted I have commented the 2 lines of code where I hide and then show the button but those also do not execute. I'm sure it has to do with the UpdatePanel/UpdateProgress but I am not clear where the code should go.
Thank You. Any insight is greatly appreciated.