This is a migrated thread and some comments may be shown as answers.

Add row to an ajaxified RadGrid does not update the grid

2 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Coax asked on 12 Nov 2012, 10:52 PM
I have a radgrid which on one of its ItemCommands, it adds a new row to the database, rebinds to the grid.
When I use normal postback it works fine, but the ajaxified version does not work. 
I've looked at the which was not much of help for me.

Here is the aspx file:

<telerik:RadScriptManager runat="server" ID="radScriptManager1" />

<telerik:RadGrid    runat="server"
                <MasterTableView AllowFilteringByColumn="False" CommandItemDisplay="None" ClientDataKeyNames="grade_id">
                        <telerik:GridSortExpression FieldName="grade_name" SortOrder="Ascending"/>
                        <telerik:GridSortExpression FieldName="sort_order" SortOrder="Ascending"/>
                        <telerik:GridTemplateColumn HeaderText="" AllowFiltering="False">
                                <asp:ImageButton runat="server" ID="lnkCopyGrade" AlternateText="Copy Grade"
                                                CommandArgument='<%# DataBinder.Eval(Container.DataItem,"grade_id") %>' 
                                                CommandName="copyGrade" ImageUrl="../../../images/icons/CopyIconSmall24x24.png" ToolTip="Copy Grade"/>
                        <telerik:GridBoundColumn    HeaderText="Full Name" DataField="grade_name" 
                                                    AllowSorting="True" AllowFiltering="False"/>
                        <telerik:GridBoundColumn HeaderText="Sort<br>Order" DataField="sort_order" ItemStyle-HorizontalAlign="Center" AllowSorting="True" AllowFiltering="False"/>
	<telerik:RadAjaxManager ID="ajaxManager1" runat="server">
                <telerik:AjaxSetting AjaxControlID="radGrid1" EventName="OnItemCommand">
                        <telerik:AjaxUpdatedControl ControlID="radGrid1" />

And here is the relevant codebehind 

	protected void radGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
	        int iGradeID = RVConversion.ToInt32(e.CommandArgument);
	        string sGradeName = radGrid1.Items[e.Item.ItemIndex].Cells[(intCOLS.NAME].Text;
            	string sURL;
            	switch (e.CommandName)
                		case "copyGrade":
 	private void CopyGrade(int gradeID)
            	var arrParams = new RVParamArrayList();
            	arrParams.addInt32Param("@gradeID", gradeID);
            	var result = RVDB.execCommand("rv_copy_grade", arrParams);
	 protected void lnkCopyGrade_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
            	object o = null;
            	IRVPageData_Base_GetData(ref o, new object[] { Entity.EntityID, null });
            	var ds = (GradeDataSet)o;
            	DataTable table = ds.Tables[0];
            	const string sAccessColumnName = "access";
            	table.Columns.Add(sAccessColumnName, Type.GetType("System.Int32"));
            	RVUserMisc.AddGradeSecurityToTable(table, sAccessColumnName, this);
            	var dv = new DataView(table);
            	radGrid1.DataSource = dv;
Worth saying that at the end of
lnkCopyGrade_OnNeedDataSource database is getting updated but from the console window of the browser I can see that following exception is thrown : Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '<!DOCTYPE html PUBLI'. Telerik.Web.UI.WebResource.axd:6
Error.create Telerik.Web.UI.WebResource.axd:6
Sys.WebForms.PageRequestManager._createPageRequestManagerParserError Telerik.Web.UI.WebResource.axd:15
Sys.WebForms.PageRequestManager._parseDelta Telerik.Web.UI.WebResource.axd:15
Sys.WebForms.PageRequestManager._onFormSubmitCompleted Telerik.Web.UI.WebResource.axd:15
(anonymous function) Telerik.Web.UI.WebResource.axd:6
(anonymous function) Telerik.Web.UI.WebResource.axd:6
Sys.Net.WebRequest.completed Telerik.Web.UI.WebResource.axd:6
_onReadyStateChange Telerik.Web.UI.WebResource.axd:6


2 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 13 Nov 2012, 11:48 PM
No one with any clue on this?
Angel Petrov
Telerik team
answered on 15 Nov 2012, 04:08 PM
Hello Coax,

This error usually reproduces when a control is not being ajaxified correctly. Could you please remove the RadAjaxManager and wrap the RadGrid in RadAjaxPanel. Sometimes setting EventName in the ajax settings for the ajax initiator control does not work. Give the upper-mentioned approach a try and let us know if the problem still persists. If it does, please open a formal support ticket with a project attached so we could investigate more thoroughly.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question