tags:

views:

237

answers:

2

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
+1  A: 
  1. Use a command column and set ShowEditButton="True" EditText="Edit" ButtonType="Link"
  2. 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") %>' />
  3. Use the EditTemplate of your column to display your edit control. ex. <asp:TextBox runat="server" id="txtMyFieldToEdit" text='<%# Eval("MyFieldToEdit") %>' />
  4. 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.