I have a method initGrdAvail() that gets the latest info for a gridview from a MySQL database and updates the gridview
private void initGrdAvail()
{
string selectedDept = drpLstDepts.SelectedItem.Text;
string query;
if (selectedDept == "ALL")
query = "SELECT unitnum,department,rank,name FROM units WHERE status='Available'";
else
query = "SELECT unitnum,department,rank,name FROM units WHERE status='Available' AND department='"+selectedDept+"'";
using (MySqlConnection con = new MySqlConnection(cnnStrData))
{
using (MySqlCommand cmd = new MySqlCommand(query))
{
cmd.Connection = con;
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
grdViewDisAvailable.DataSource = ds;
grdViewDisAvailable.DataBind();
}
}
}
This method works fine when calling it on a button click event, or a selected index changed event on a drop down list.
Here is where it's called from SignalR:
HubProxyRegister.On<string, string>("UpdateUnitStatus", (username, status) =>
{ initGrdAvail(); });
However, when calling this method from an incoming Signalr event it does not update the gridview. I can see that this method is being called and ran fully through debugging, but it only displays the updated gridview on the page when the method is called from some sort of button event.
I am fairly new to ASP.NET, does this have something to do with Signalr not using a postback or something? I've tried searching around a bit but haven't had much luck yet.
Thanks!