I have a gridview with "Edit Update Cancel" command field. When I click Edit, all the columns in the particular row becomes editable. I just need to have 2 specific columns editable. How is that made possible ?
(Screen Shot Attached)
[In the screen shot all 3 columns are editable, I just need the secon开发者_Go百科d and third to be editable]
Thanks in Advance.
Just set the other columsn to read-only:
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" />
It is very easy. The column you want not editable then place just label and bind properly.
<EditItemTemplate>
<asp:Label Runat="server" Text='<%# Bind("UnitPrice", "{0:c}") %>' ID="Label1"></asp:Label>
</EditItemTemplate>
Here I use label in my EditItemTemplate
because when the user clicks on edit button, the textbox will not come up. Rather, the value for that record will show through label, and as a result the user can not update that field.
精彩评论