8 Answers, 1 is accepted
I suppose you are using Simple databinding. In order to achieve this, use advanced databinding techniques using NeedDataSource event. This event fires whenever a paging operation occurs. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event).
Thanks,
Princy.
This is my code and the page did not get refresh when i did a page navigation. thanks
Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = Session("sessiondataset")
End Sub
Sorry, i need to rephase my intention.
I have got it wrong when i used the word refresh a page, instead it should be forcing a postback of a radgrid when paging.
Thanks
Do you mean that you want to make a postback instead of AJAX request when paging? If so, you could wire the client OnRequestStart event of the RadAjaxManager/Panel and cancel the request on certain condition. You could recognize the Page command in the client OnCommand event of RadGrid and raise a flag to use for checking in the OnRequestStart event handler.
Greetings,
Tsvetina
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Yes i want the a postback when users do page navigation
I have gone through some of the forums and have taken this code and i am still wonder how should i go about it.
<script type="text/javascript">
function RequestStart(sender, eventArgs)
{
var eventTarget = eventArgs.get_eventTarget();
if (eventTarget.indexOf("Button1") != -1)
{
eventArgs.set_enableAjax(false);
}
function RaiseCommand(sender, args)
{
if (args.get_commandName() == 'Page')
{
args.set_cancel(false);
}
}
}
</script>
What should i replace with on the eventTarget.indexOf("Button1") != -1 since i am not using a button and how do i go about "You could recognize the Page command in the client OnCommand event of RadGrid and raise a flag to use for checking in the OnRequestStart event handler" Thanks and sorry for any inconvenience cause.
Here is sample code that you could try. The OnCommand event checks whether the command is Page and raises a flag indicating to turn off AJAX for the current request which is done in OnRequestStart handler:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
style
type
=
"text/css"
>
</
style
>
<
script
type
=
"text/C#"
runat
=
"server"
>
protected void Page_Load(object sender, EventArgs e)
{
RadGrid1.DataSource = new object[]
{
new { Text = "1", MoreText = "More text than the previous field." },
new { Text = "2", MoreText = "More text than the previous field." },
new { Text = "3", MoreText = "More text than the previous field." },
new { Text = "4", MoreText = "More text than the previous field." },
new { Text = "5", MoreText = "More text than the previous field." },
new { Text = "6", MoreText = "More text than the previous field." },
new { Text = "7", MoreText = "More text than the previous field." },
new { Text = "8", MoreText = "More text than the previous field." },
new { Text = "9", MoreText = "More text than the previous field." },
new { Text = "10", MoreText = "More text than the previous field." },
new { Text = "11", MoreText = "More text than the previous field." },
new { Text = "12", MoreText = "More text than the previous field." }
};
RadGrid1.DataBind();
}
</
script
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
div
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var isPaging;
function command(sender, eventArgs) {
if (eventArgs.get_commandName() == 'Page') {
isPaging = true;
}
}
function requestStart(sender, eventArgs) {
if (isPaging) {
eventArgs.set_enableAjax(false);
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
ClientEvents-OnRequestStart
=
"requestStart"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowSorting
=
"true"
AllowPaging
=
"true"
>
<
ClientSettings
ClientEvents-OnCommand
=
"command"
/>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Text"
ItemStyle-Width
=
"200px"
HeaderStyle-Width
=
"200px"
HeaderText
=
"Text"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MoreText"
ItemStyle-Width
=
"200px"
HeaderStyle-Width
=
"200px"
HeaderText
=
"More Text"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
telerik:RadAjaxPanel
>
</
div
>
</
form
>
</
body
>
</
html
>
Regards,
Tsvetina
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Hi Krupa,
The Telerik ASP.NET AJAX controls are not designed and intended for use in MVC environment. Please check the following article on the matter:
https://docs.telerik.com/devtools/aspnet-ajax/mvc/overview.
We recommend using the UI for ASP.NET MVC, the Telerik product built from the ground up to support the principles of MVC development in your MVC projects. The MVC suite is pretty mature and offers a similar amount of ASP.NET MVC components (100+).
You can play with the MVC Grid demos at https://demos.telerik.com/aspnet-mvc/grid.
On a side note, version 2013.2.611 of Telerik.Web.UI.dll is pretty old and does not support the latest browsers.
Regards,
Rumen
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.