gridview 增删改查 分页 sqlserver数据库

本文介绍了如何使用ASP.NET的GridView控件结合SQLServer数据库,实现数据的添加、删除、修改和分页功能。通过TextBox输入数据,Button触发操作,后端服务器处理并更新到数据库。
摘要由CSDN通过智能技术生成

前台:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lianxi1.aspx.cs" Inherits="WebApplication1.lianxi1" %>

<!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" >
<head runat="server">
   <title>无标题页</title>
      
        <style type="text/css">
            .style1
            {
                width: 151px;
            }
            .style2
            {
                width: 176px;
            }
            .style3
            {
                width: 197px;
            }
        </style>
      
</head>
<body>
    <form id="form1" runat="server">
  
        <asp:GridView ID="GridView1" runat="server" 
            OnRowDeleting="GridView1_RowDeleting" DataKeyNames="pkID" 
        OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" 
        OnRowEditing="GridView1_RowEditing"  
            style ="left:50px;vertical-align:middle;width:700px;height:200px;text-align:center" 
            AutoGenerateColumns="False"  AllowPaging="true" 
            onpageindexchanging="GridView1_PageIndexChanging" 
            onrowcommand="GridView1_RowCommand">
        <Columns>
        <asp:CommandField ShowDeleteButton = "True" >
            <ItemStyle Width="100px" />
            </asp:CommandField>
        <asp:CommandField ShowEditButton ="True" >
            <ItemStyle Width="100px" />
            </asp:CommandField>
            <asp:BoundField HeaderText="姓名" DataField="Name"  >
                <ItemStyle Width="100px" />
            </asp:BoundField>
            <asp:BoundField HeaderText="性别" DataField="Sex" >
                <ItemStyle Width="100px" />
            </asp:BoundField>
            <asp:BoundField HeaderText="住址" DataField="Address" >
                <ItemStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField HeaderText="出生地" DataField="Born" >
                <ItemStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField HeaderText="代码" DataField="Code" >
                <ItemStyle Width="100px" />
            </asp:BoundField>
       </Columns>
       <PagerTemplate>
            <asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)
            Container.NamingContainer).PageIndex + 1) + "页/共" + (((GridView)
            Container.N
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值