Why doesnt the AsyncCallback update my gridview?
- by Naruji
Hi all,
I started working with delegates last week and i am trying to update my gridview async on the background. All goes well, no errors or such but i dont get a result after my EndInvoke. does anyone know what i am doing wrong?
Here is a code snippet:
public delegate string WebServiceDelegate(DataKey key);
protected void btnCheckAll_Click(object sender, EventArgs e)
{
foreach (DataKey key in gvTest.DataKeys)
{
WebServiceDelegate wsDelegate = new WebServiceDelegate(GetWebserviceStatus);
wsDelegate.BeginInvoke(key, new AsyncCallback(UpdateWebserviceStatus), wsDelegate);
}
}
public string GetWebserviceStatus(DataKey key)
{
return String.Format("Updated {0}", key.Value);
}
public void UpdateWebserviceStatus(IAsyncResult result)
{
WebServiceDelegate wsDelegate = (WebServiceDelegate)result.AsyncState;
Label lblUpdate = (Label)gvTest.Rows[Convert.ToInt32(key.Value)].FindControl("lblUpdate");
lblUpdate.Text = wsDelegate.EndInvoke(result);
}