asp 上机实验数据绑定.docx
- 文档编号:9242313
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:29
- 大小:104.57KB
asp 上机实验数据绑定.docx
《asp 上机实验数据绑定.docx》由会员分享,可在线阅读,更多相关《asp 上机实验数据绑定.docx(29页珍藏版)》请在冰豆网上搜索。
asp上机实验数据绑定
数学与计算机学院
上机报告
(2012/2013学年第2学期)
课程名称
ASP.NET网站开发
课程代码
6014789
上机时间
2013
年
5
月
17
日
指导单位
任课教师
李颖
学生姓名
杨玲
年级
2011级
学号
312011*********
专业
软件工程
成绩
实验名称
数据绑定
实验地点
6A418
实验类型
实验学时
实验日期
实验目的和要求
1实验目的
熟悉ASP.NET中的数据绑定,掌握使用GridView、DataList、FormView进行数据的显示和处理的方法。
2实验要求
建立一个网站,实现用数据绑定的操作。
实验环境(实验设备)
MicrosoftVisualStudio2010,MicrosoftSQLsever2008数据库管理系统。
配置网络环境的计算机系统,安装有IIS
实验原理及内容
1.实验原理及内容
(1)建立一个DBExercise网站
(2)在网站中建立一个Student数据库表
(3)添加一个网页,用GridView分页
(4)添加一个网页,用DataList分页
(5)添加一个网页,用FromView实现数据的插入、删除、修改等。
2.实验过程
FormViewBinding.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="FormViewBinding.aspx.cs"Inherits="FormViewBinding"%>
DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:
//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//www.w3.org/1999/xhtml">
FormViewID="FormView1"runat="server"DataKeyNames="no" DataSourceID="SqlDataSource1"AllowPaging="True"CellPadding="4" ForeColor="#333333"Width="231px"> PreviousPageText="上一页<"/> 100%;"> LabelID="Label1"runat="server"Text="学号"Width="100%"> Label> LabelID="noLabel1"runat="server"Text='<%#Eval("no")%>'/> LabelID="Label2"runat="server"Text="姓名"Width="100%"> Label> TextBoxID="nameTextBox"runat="server"Text='<%#Bind("name")%>'/> LabelID="Label3"runat="server"Text="生日"Width="100%"> Label> TextBoxID="birthTextBox"runat="server"Text='<%#Bind("birth")%>'/>
LabelID="Label4"runat="server"Text="地址"Width="100%"> Label> TextBoxID="addressTextBox"runat="server"Text='<%#Bind("address")%>'/>
LinkButtonID="UpdateButton"runat="server"CausesValidation="True"CommandName="Update"Text="更新"/> LinkButtonID="UpdateCancelButton"runat="server"CausesValidation="False"CommandName="Cancel"Text="取消"/>
100%;"> LabelID="Label2"runat="server"Text="姓名"Width="100%"> Label> TextBoxID="nameTextBox"runat="server"Text='<%#Bind("name")%>'/>
LabelID="Label3"runat="server"Text="生日"Width="100%"> Label> TextBoxID="birthTextBox"runat="server"Text='<%#Bind("birth")%>'/>
LabelID="Label4"runat="server"Text="地址"Width="100%"> Label> TextBoxID="addressTextBox"runat="server"Text='<%#Bind("address")%>'/>
LinkButtonID="InsertButton"runat="server"CausesValidation="True"CommandName="Insert"Text="插入"/> LinkButtonID="InsertCancelButton"runat="server"CausesValidation="False"CommandName="Cancel"Text="取消"/>
100%;"> LabelID="Label1"runat="server"Text="学号"Width="100%"> Label> LabelID="noLabel"runat="server"Text='<%#Eval("no")%>'/>
LabelID="Label2"runat="server"Text="姓名"Width="100%"> Label> LabelID="nameLabel"runat="server"Text='<%#Bind("name")%>'/>
LabelID="Label3"runat="server"Text="生日"Width="100%"> Label> LabelID="birthLabel"runat="server"Text='<%#Bind("birth")%>'/>
LabelID="Label4"runat="server"Text="地址"Width="100%"> Label> LabelID="addressLabel"runat="server"Text='<%#Bind("address")%>'/>
LinkButtonID="NewButton"runat="server"CausesValidation="True"CommandName="New"Text="新建"/> LinkButtonID="EditButton"runat="server"CausesValidation="False"CommandName="Edit"Text="更新"/> LinkButtonID="DeleteButton"runat="server"CausesValidation="False"CommandName="Delete"Text="删除"/>
学生详细信息
FormView>
SqlDataSourceID="SqlDataSource1"runat="server" ConnectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydatabase.mdf;IntegratedSecurity=True;UserInstance=True" ProviderName="System.Data.SqlClient" SelectCommand="SELECT[no],[name],[birth],[address]FROM[student]" InsertCommand="INSERTINTOstudent(name,birth,address)VALUES(@name,@birth,@address)" DeleteCommand="DELETEFROMstudentWHERE(no=@no)" UpdateCommand="updatestudentsetname=@name,birth=@birth,address=@addresswhereno=@no">
SqlDataSource>