<%@ Page Language="C#" Theme="" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head id="Head1" runat="server"> <title>ASP.NET Insert data in Gridview </title> </head><body> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:GridView ID="GridView1" ShowFooter="true" runat="server" OnRowCommand="GridView1_RowCommand1" AutoGenerateColumns="false"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button Text="Edit" CommandName="Edit" CausesValidation="false" runat="server" ID="btEdit" /> <asp:Button Text="Delete" CommandName="Delete" CausesValidation="false" runat="server" ID="btDelete" /> </ItemTemplate> <EditItemTemplate> <asp:Button Text="Update" CommandName="Update" CausesValidation="true" runat="server" ID="btUpdate" /> <asp:Button Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" ID="btCancel" /> </EditItemTemplate> <FooterTemplate> <asp:Button Text="Insert" CommandName="Insert" CausesValidation="true" runat="server" ID="btInsert" /> <asp:Button Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" ID="btCancel" /> </FooterTemplate> </asp:TemplateField> <asp:TemplateField > <ItemTemplate> <asp:Label ID="lblValue" Text='<%# Eval("Name") %>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="tbUpdate" runat="server" Text='<% Bind("Name") %>'></asp:TextBox> </EditItemTemplate> <FooterTemplate> <asp:TextBox ID="tbInsert" runat="server" Text="" ></asp:TextBox> </FooterTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate> <asp:TextBox ID="tbEmptyInsert" runat="server"></asp:TextBox><br /> <asp:Button ID="btSend" Text="Insert" runat="server" CommandName="EmptyInsert" UseSubmitBehavior="False" /> </EmptyDataTemplate> </asp:GridView> </form> </body></html>And the code behind : 14 public partial class Test : System.Web.UI.Page 相关文章: 2021-08-27 2022-12-23 2022-12-23 2022-12-23 2022-12-23 2022-12-23 2022-12-23 2021-05-15