Kar*_*arl 8 c# asp.net gridview edit visual-studio-2010
我正在使用gridview编辑来编辑我在gridview中的值,当我按下编辑时,所有列都可以编辑,我希望不允许编辑其中一列.
有什么方法可以做到这一点吗?
这是我的aspx代码:
<asp:GridView
ID="GridView1"
runat="server"
AllowSorting="True"
OnRowCommand="GridView1_SelectedIndexChanged1"
AutoGenerateEditButton="True"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
CellSpacing="10"
OnRowUpdating="GridView1_RowUpdating" ShowFooter="True"
onselectedindexchanged="GridView1_SelectedIndexChanged"
OnRowEditing="GridView1_RowEditing">
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
谢谢
nav*_*een 24
如果您正在使用asp:BoundField,请尝试
<asp:BoundField DataField="CustomerID"
ReadOnly="true"
HeaderText="Customer ID"/>
Run Code Online (Sandbox Code Playgroud)
或者,如果你正在使用asp:TemplateField,你也可以
asp:Label内部渲染它EditItemTemplateEditItemTemplate完全忽略该列当然,请使用EditItemTemplate.在以下示例中,不会在编辑模式下编辑字段ID:
<asp:GridView runat="server">
<Columns>
...
<asp:TemplateField HeaderText="ID">
<EditItemTemplate>
<%# Eval("ID") %>
</EditItemTemplate>
</asp:TemplateField>
...
</Columns>
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32878 次 |
| 最近记录: |