【发布时间】:2017-12-31 18:35:06
【问题描述】:
使用 vb.net 4.5 和 Telerik 2017.2.711.45(第二季度) 我正在尝试获取 radgrid 过滤器表达式和一个公共字符串变量以在回发中持续存在。
对于EnableViewState=FALSE,radgrid 过滤器表达式不会在回发中持续存在,但是公共字符串变量 (stringVar)会持续存在。
当我设置 EnableViewState=TRUE 时,radgrid 中的过滤器表达式 do 保持不变,但它会导致 stringVar 不保持不变。
根据我对 ViewState 的理解,设置 EnableViewState=TRUE 会导致 stringVar 不会在回发中持续存在是没有意义的。我很想知道为什么会发生这种情况以及我可以做些什么来解决这个问题。
编辑: 突出显示的 Line 是由于 ReportTitle 不再具有值而引发错误的地方。
Partial Class displayxslgrid
Public ReportTitle As String
Public ReportsDB As reportDataBase
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.EnableViewState = True
Reports = New reportDataBase.Global_Functions(System.Web.HttpContext.Current)
End Sub
Protected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
Call BindRadGrid1()
End Sub
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
Dim strReportTitle As String
Select Case e.CommandName
Case RadGrid.ExportToExcelCommandName, RadGrid.ExportToWordCommandName, RadGrid.ExportToCsvCommandName
strReportTitle = ReportTitle.Trim
End Select
End Sub
Public Sub BindRadGrid1()
Dim strReportTitle As String
Dim dt As DataTable = Nothing
ReportTitle = dt.Rows(0).Item("ReportTitle")
strReportTitle = dt.Rows(0).Item("ReportTitle").ToString
'RadGrid1 Data source gets set here along with other stuff
End Sub
End Class
【问题讨论】:
标签: asp.net vb.net telerik viewstate