Here is what my button click event looks like:
protected void btnSave_Click(object sender, EventArgs e)
{
// Save logic goes here
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "saveCallback", "SaveGridChanges();", true);
}
As you can see I am trying to call the function SaveGridChanges(); js function after the save logic runs.
function SaveGridChanges()
{
var radGrid1 = $find('<%=RadGrid1.ClientID%>');
radGrid1.get_batchEditingManager().saveChanges(radGrid1.get_masterTableView());
}
The problem is that I am getting JavaScript errors when the function is called because it is unable to find the grid. This is most likely because the script is trying to run before the grid is output on the page. Any suggestions on what I can do here?
The exact error messages are:
Uncaught TypeError: Cannot read property 'get_batchEditingManager' of null. Uncaught TypeError: Cannot read property 'disable' of null.
I have tried registering the script on both page_load and pre_render and the grid still isn't available at those times. This makes no sense.