首页 > 其他 > 详细

Gridview

时间:2016-01-11 00:03:06      阅读:220      评论:0      收藏:0      [点我收藏+]

前台:

<!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}

Gridview

原文:http://www.cnblogs.com/zhubenxi/p/5119898.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!