标签:
前台:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label3" runat="server" Text="Label">1</asp:Label><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="Label">2</asp:Label><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label">3</asp:Label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:GridView ID="GridView1" AutoGenerateColumns="false" DataKeyNames="ID" runat="server" DataSourceID="AccessDataSource1"> <Columns>
<asp:BoundField DataField="ID" HeaderText ="id" InsertVisible ="false" ReadOnly ="true" SortExpression ="ID" />
<asp:BoundField DataField ="T_user" HeaderText ="123" SortExpression ="T_user" />
<asp:BoundField DataField ="T_pass" HeaderText ="223" SortExpression ="T_pass" />
<asp:BoundField DataField ="T_phone" HeaderText ="333" SortExpression ="T_phone" />
<asp:BoundField DataField ="T_dz" HeaderText ="dz" SortExpression ="T_dz" />
<asp:BoundField DataField ="T_em" HeaderText ="dm" SortExpression ="T_em" />
<asp:BoundField DataField ="T_qq" HeaderText ="T_qq" SortExpression ="T_qq" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" /></Columns> </asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/admin_user.mdb"
SelectCommand ="select * from [user]"
DeleteCommand ="Delete from [user] where (ID=?)"
InsertCommand="INSERT INTO [user](T_user, T_pass,T_phone,T_dz) VALUES (?,?,?,‘aaa‘)"
UpdateCommand="update [user] set T_user=?,T_pass=? where ID=?" >
<InsertParameters ><asp:ControlParameter ControlID="TextBox1" Name ="T_user" PropertyName="Text" />
<asp:ControlParameter ControlID ="TextBox2" Name="T_pass" PropertyName="Text" />
<asp:ControlParameter ControlID ="TextBox3" Name ="T_phone" PropertyName ="Text" />
</InsertParameters></asp:AccessDataSource>
</div> </form> </body> </html>
对Gridview 的增删改查只button调用 数据 源的insert()及可。其它 gridview 可自行处理。
access mdb文件表 结构:user{id,T_user,T_pass,T_phone,T_dz,T_em}
标签:
原文地址:http://www.cnblogs.com/zhubenxi/p/5119898.html