前台
- C# code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting" DataKeyNames="UserID" OnRowCancelingEdit="GridView1_RowCancelingEdit"> <Columns> <asp:TemplateField HeaderText="用户ID"> <EditItemTemplate> <asp:Label ID="Label5" runat="server" Text='<%# Bind("UserID") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Bind("UserID") %>'></asp:Label> </ItemTemplate> <FooterTemplate> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="UserLogin" SortExpression="UserLogin"> <EditItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Eval("UserLogin") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Bind("UserLogin") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="UserLogins" runat="server"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="UserPwd" SortExpression="UserPwd"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("UserPwd") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("UserPwd") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="UserPwds" runat="server"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Xzhe" SortExpression="Xzhe"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Xzhe") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("Xzhe") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="Xzhes" runat="server"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField ShowHeader="False"> <EditItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="更新"></asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="取消"></asp:LinkButton> </EditItemTemplate> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="编辑"></asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="删除" OnClientClick="return confirm('你确定要删除吗?')"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> <RowStyle BackColor="#E3EAEB" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView>