本文介绍了Telerik的radgrid控件在编辑模式下设置绑定列到只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Telerik的radgrid控件具有三个绑定列和一个按钮列。我想,让用户只在绑定列的一个编辑值。用户可以添加一个新的记录,所以我不能设置两个绑定列只读。反正我有可以在ASPX做到这一点还是我必须这样做,在后面的代码?我有一些代码,是工作,但它是不是最好的。
下面是我的代码:
案例编辑
昏暗aoeAnswerCode作为GridBoundColumn = CTYPE(e.Item.OwnerTableView.GetColumn(aoeAnswerCode),GridBoundColumn)
aoeAnswerCode。只读= TRUE
案更新,PerformInsert
。对于每一列的GridColumn在e.Item.OwnerTableView.RenderColumns
如果TypeOf运算列是IGridEditableColumn或者column.UniqueName = aoeAnswerCode然后
解决方案
只需将只读
属性真正
。请参见下面的例子:
< Telerik的:GridBoundColumn数据字段=日期时间的HeaderText =日期
DataFormatString = {0:MM / DD / YYYY}只读=真>
< / Telerik的:GridBoundColumn>
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
解决方案
Simply set the ReadOnly
property to true
. See the example below:
<telerik:GridBoundColumn DataField="Datetime" HeaderText="Date"
DataFormatString="{0:MM/dd/yyyy}" ReadOnly="True">
</telerik:GridBoundColumn>
这篇关于Telerik的radgrid控件在编辑模式下设置绑定列到只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!