How can I do editable GridView Template Cells TextBox?
A:
I think here is answer http://www.codeproject.com/KB/webforms/GridView%5Fall%5Fin%5Fone.aspx
Unholy
2009-12-04 14:37:14
+1
A:
- Use a command column and set
ShowEditButton="True" EditText="Edit" ButtonType="Link"
- In your template column use the ItemTemplate to describe what the columns should look like in non-edit mode using
<asp:Label runat="server" id="txtMyLabel" text='<%# Eval("MyFieldToDisplay") %>' />
- Use the EditTemplate of your column to display your edit control. ex.
<asp:TextBox runat="server" id="txtMyFieldToEdit" text='<%# Eval("MyFieldToEdit") %>' />
Handle the GridView.OnEditing event as such
protected void myGridView_OnEditing(object sender, GridViewEditingEventArgs e) { myGridView.EditIndex=e.RowIndex; }
I believe these are the right property/attribute names, but I'm typing off the top of my head...
you'll more than likely need to handle OnCancelEdit as well and enable the cancel button in your command column.