Hi,
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 http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-not-refreshing-after-ajax-and-rebind.aspx which was not much of help for me.
Here is the aspx file:
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 http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-not-refreshing-after-ajax-and-rebind.aspx which was not much of help for me.
Here is the aspx file:
<telerik:RadScriptManager runat="server" ID="radScriptManager1" />
<telerik:RadGrid runat="server"
ID="radGrid1"
AutoGenerateColumns="False"
EnableViewState="True"
OnItemCreated="radGrid1_OnItemCreated"
OnItemCommand="radGrid1_OnItemCommand"
OnNeedDataSource="lnkCopyGrade_OnNeedDataSource">
<MasterTableView AllowFilteringByColumn="False" CommandItemDisplay="None" ClientDataKeyNames="grade_id">
<SortExpressions>
<telerik:GridSortExpression FieldName="grade_name" SortOrder="Ascending"/>
</SortExpressions>
<SortExpressions>
<telerik:GridSortExpression FieldName="sort_order" SortOrder="Ascending"/>
</SortExpressions>
<Columns>
<telerik:GridTemplateColumn HeaderText="" AllowFiltering="False">
<ItemTemplate>
<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"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
<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"/>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadAjaxManager ID="ajaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="radGrid1" EventName="OnItemCommand">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
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[(int) COLS.NAME].Text;
string sURL;
switch (e.CommandName)
{
case "copyGrade":
CopyGrade(iGradeID);
break;
}
}
private void CopyGrade(int gradeID)
{
//rv_copy_grade
var arrParams = new RVParamArrayList();
arrParams.addInt32Param("@gradeID", gradeID);
var result = RVDB.execCommand("rv_copy_grade", arrParams);
radGrid1.Rebind();
}
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
Thanks.