我将我的 radGrid 的数据源设置为一个数据集(我存储在会话中)。我启用了 AllowAutomaticUpdates 和 EnableViewState,实现了 NeedDataSource,设置了 DatakeyNames 等(参见下面的代码)
但是,当我按下编辑按钮并进行更改并按下更新链接时,记录不会更新并离开编辑模式......它只是停留在编辑模式,不会发生任何错误。
所以,问题是......有谁知道带有 EnableViewstate 的 radGrid 是否甚至支持 AutomaticUpdates,所以网格中的更改将自动推送到它所绑定的数据集中?
有人会认为您可以阅读文档,但我一直无法找到明确的答案。
谢谢
<telerik:Radgrid id="grid" runat="server" AllowPaging="True" AllowSorting="True" AllowAutomaticUpdates="true"
AutoGenerateEditColumn="True" GridLines="None" >
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim data As New DataGateway
Dim ds As DataSet = data.GetEmployeesByProgram(Year:=2009, ProgramName:="Long Term Incentive Stock Program")
Dim dt As DataTable = ds.Tables(0)
ds.Tables(0).PrimaryKey = New DataColumn() {dt.Columns("EmployeeNum"), dt.Columns("ProgramName"), dt.Columns("Year")}
Session("datasource") = ds
With Me.grid
.AllowAutomaticUpdates = True
.AutoGenerateColumns = True
.AllowSorting = True
.AutoGenerateEditColumn = True
.EnableViewState = True 'IS REQUIRED!!!
Me.grid.MasterTableView.AllowAutomaticUpdates = True
Me.grid.MasterTableView.EditMode = GridEditMode.InPlace
End With
End If
End Sub
Private Sub grid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grid.NeedDataSource
Debug.WriteLine("NeedDataSource: " & e.RebindReason.ToString)
Dim ds As DataSet = CType(Session("datasource"), DataSet)
Me.grid.MasterTableView.DataKeyNames = New String() {"EmployeeNum", "ProgramName", "Year"}
Me.grid.DataSource = ds
End Sub