I have GridView bound to some List. In layout I created following template field:
<asp:TemplateField HeaderText="Phrase">
<ItemTemplate>
<asp:TextBox ID="phraseTextBox" runat="server" Text='<%# Bind("Phrase") %>'/>
</ItemTemplate>
</asp:TemplateField>
But after changing the content of any TextBox in column “Phrase” my List doesn’t reflect that changes.
What I did wrong?:)
ItemTemplate will be used only for display/view purpose. You need to have EditItemTemplate to specify how the UI will be while editing the row. Not only that, but you also have to add button/link to the row to push it into an edit mode.
Read this article from MSDN that explains how to edit data using grid-view. Check example under section “Adding Validation Controls to the Editing Interface” for use of EditItemTemplate.