我已经尝试过从我读到的所有内容(从添加需求源到添加pageindexchanged等等),但仍然无法弄明白......任何帮助都会感激不尽......
以下是我的代码......
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadAjaxManager ID="ram1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ajaxtimer1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rgNewsFeed" LoadingPanelID="LoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" />
<telerik:RadGrid ID="rg1" runat="server" ShowStatusBar="True" AllowPaging="true" >
<MasterTableView AutoGenerateColumns="False" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn DataField="CommentSubject" HeaderText="Subject" />
<telerik:GridHyperLinkColumn DataTextField="CommentText" DataTextFormatString="{0}" DataNavigateUrlFormatString="~/Views/m.aspx?pEntityID={0}"
DataNavigateUrlFields="CmtTextID" HeaderText="Details" UniqueName="gbcCommentText" />
<telerik:GridBoundColumn DataField="EntityFundName" HeaderText="Entity/Fund" />
<telerik:GridBoundColumn DataField="EnteredBy" HeaderText="Entered by" />
<telerik:GridBoundColumn DataField="CommentAge" HeaderText="Last Updated" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:Panel ID="Panel1" runat="server">
<asp:Timer ID="Timer1" runat="server" Interval="3000">
</asp:Timer>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
背后的代码
Protected Sub OnLoad(sender As Object, e As System.EventArgs) Handles Me.Load
rg1.DataSource = dt 'some datatable
rg1.DataBind()
End Sub
Public Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
rg1.DataSource = dt 'some datatable
System.Threading.Thread.Sleep(500)
End Sub
Protected Sub rgLeoNotesNewsFeed_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgLeoNotesNewsFeed.NeedDataSource
rg1.DataSource = dt 'some datatable
End Sub
答案 0 :(得分:1)
首先,我将asp:UpdatePanel
替换为telerik:RadAjaxPanel
。我不得不使用telerik组件一段时间,没有最好的时间。如果您正在使用radgrid并且要使用updatepanel,请使用相应的telerik组件,例如telerik:RadAjaxPanel
。通过这种方式,您将遇到更少的问题。
其次,我对以下部分感到困惑
<telerik:AjaxSetting AjaxControlID="ajaxtimer1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rgNewsFeed" LoadingPanelID="LoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
您似乎没有ID为rgNewsFeed
和ajaxtimer1
的任何控件。你基本上是说 RadAjaxManager 来更新 ajaxtimer1 更新中的 rgNewsFeed 。
这不应该像
<telerik:AjaxSetting AjaxControlID="Timer1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rg1" LoadingPanelID="LoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
此外,您需要像这样
<telerik:AjaxSetting AjaxControlID="rg1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rg1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
不确定您的问题是否与这些相关,但请尝试一下,看看是否有效。
修改强>
Protected Sub OnLoad(sender As Object, e As System.EventArgs) Handles Me.Load
rg1.DataSource = dt 'some datatable
rg1.DataBind()
End Sub
我认为你应该在每次调用时设置数据源,但只有在它不是回发时才调用DataBind
方法。请尝试以下方法。
Protected Sub OnLoad(sender As Object, e As System.EventArgs) Handles Me.Load
rg1.DataSource = dt 'some datatable
If Not IsPostBack Then
rg1.DataBind()
End If
End Sub