Telerik RadGrid 在编辑模式下将 BoundColumn 设置为 ReadOnly
我有一个 Telerik RadGrid,它具有三个绑定列和一个按钮列。我想让用户仅编辑绑定列之一中的值。用户可以添加新记录,因此我无法将两个绑定列设置为只读。无论如何,我可以在 ASPX 中执行此操作还是必须在后面的代码中执行此操作?我有一些代码可以工作,但它不是最好的。
这是我的代码:
Case "Edit"
Dim aoeAnswerCode As GridBoundColumn = CType(e.Item.OwnerTableView.GetColumn("aoeAnswerCode"), GridBoundColumn)
aoeAnswerCode.ReadOnly = True
Case "Update", "PerformInsert"
For Each column As GridColumn In e.Item.OwnerTableView.RenderColumns
If TypeOf column Is IGridEditableColumn Or column.UniqueName = "aoeAnswerCode" Then
I have a Telerik RadGrid that has three bound columns and one button column. I would like to let the user edit the values in only one of the bound columns. The user can add a new record so i can't set the two bound column to read only. Is there anyway i can do this in the ASPX or do i have to do it in the code behind? I have some code that is working but it is not the best.
Here's my code:
Case "Edit"
Dim aoeAnswerCode As GridBoundColumn = CType(e.Item.OwnerTableView.GetColumn("aoeAnswerCode"), GridBoundColumn)
aoeAnswerCode.ReadOnly = True
Case "Update", "PerformInsert"
For Each column As GridColumn In e.Item.OwnerTableView.RenderColumns
If TypeOf column Is IGridEditableColumn Or column.UniqueName = "aoeAnswerCode" Then
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将
ReadOnly
属性设置为true
即可。请参阅下面的示例:Simply set the
ReadOnly
property totrue
. See the example below:.aspx 页面代码
aspx.cs 页面代码
.aspx page code
aspx.cs page code