版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、盅案解三方案匿懑国理器忆m+:j a皿蝶访累4 a4项目) © chaxun一门 Detaultaspxb Defauk.a印/e® Web.cenfig里 zergji.a5pK巧工angjim.a淮北查询页面讥行皆洱全选瘴w编号2姓名 李四6地址上海电话12345678911修改黑辑4帏伟21长沙12345678913熊据L5哈吉43北京12345678923诵6FAD18北京12345678973编辑刘圆圆31天津12345678943编据BDER21天津12345678972编辑9AVQW21苏州12345678919编辑10DD21上海12345678924褊辑1
2、1小李21 _武汉12345678941僦12qdd21上海12234245320编辑百页前贡第项洪4页后笈尾至1贝转到蠕加更新删除页面执行登询主选择v编号姓名铺|地址电话修改季四6£海123456789114伟伟21长沙12345678913编辑5哈吉43d匕京12345678923编辑r5FAD18口匕京12345678973编辑1刘囱国3112345678943编辑3DER21庆津12345678972编辑?WQW21苏州12345678919媪辑10DD21上海12345678924编辑11小李21武双12345678941编辑12qdd|21I上海12234245320垂翱
3、取消删除芽贝前页第1页洪4页后巫屋亘n一页两增加页面以下是代码<% Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server"><meta http
4、-equiv="Content-Type" content="text/html; charset=utf-8”/> <title></title></head><body><form id="form1" runat="server"><div><asp:Button ID="btnExecute" runat="server" Text="执行查询OnClick="btnExec
5、ute_Click” /><asp:Label ID="lblCount" runat="server" ></asp:Label><br /><asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"></asp:DropDownList><br /><asp:GridView ID="GridView1"
6、runat="server" DataKeyNames="Id" AutoGenerateColumns="False”OnRowCancelingEdit="GridView1_RowCancelingEdit"OnRowEditing="GridView1_RowEditing"OnRowUpdating="GridView1_RowUpdating"OnRowDeleting="GridView1_RowDeleting" AllowPaging="
7、true" AllowSorting="true"OnPageIndexChanging="GridView1_PageIndexChanging"><Columns><asp:BoundField DataField="Id" HeaderText="编号 "ReadOnly="true"/><asp:BoundField DataField="Name" HeaderText="姓名 " /><
8、asp:BoundField DataField="Age" HeaderText="年龄 " /><asp:BoundField DataField="Address" HeaderText="地址 "/><asp:BoundFieldDataField="Phone" HeaderText=" 电话 " /><asp:TemplateField HeaderText="修改 "ShowHeader="fal
9、se"><ItemTemplate><asp:LinkButton ID="LinkButton3"runat="server" CausesValidation="False"CommandName="Edit" Text="编辑"></asp:LinkButton></ItemTemplate><EditItemTemplate><asp:LinkButton ID="LinkButton1"
10、;runat="server" CausesValidation="true"CommandName="Update" Text="更新"></asp:LinkButton><asp:LinkButton ID="LinkButton2"runat="server" CausesValidation="true"CommandName="Cancel" Text="取消"></as
11、p:LinkButton><asp:LinkButton ID="LinkButton3"runat="server" CausesValidation="true"CommandName="delete" Text="删除"></asp:LinkButton></EditItemTemplate></asp:TemplateField></Columns><%-分页功能-%><PagerTemplate>
12、<asp:LinkButton ID="cmdFirstPage" runat="server"CommandName="Page" CommandArgument="First"Enabled="<%#(GridView)Container.Parent.Parent).PageIndex!=0 %>"> 首页</asp:LinkButton><asp:LinkButton ID="cmdPreview" runat="s
13、erver"CommandName="Page" CommandArgument="Prev"Enabled="<%#(GridView)Container.Parent.Parent).PageIndex!=0 %>"> 前页</asp:LinkButton>第 <asp:Label ID="lblcurPage" ForeColor="Blue" runat="server"Text='<%#(GridView)
14、Container.Parent.Parent).PageIndex+1 %>'></asp:Label> 页 / 共<asp:Label ID="lblPageCount" ForeColor="blue"runat="server"Text='<%#(GridView)Container.Parent.Parent).PageCount %>'></asp:Label> 页<asp:LinkButton ID="cmdNext&qu
15、ot; runat="server"CommandName="Page" CommandArgument="Next"Enabled="<%#(GridView)Container.Parent.Parent).PageIndex!=(GridView)Container.Parent.Parent).PageCount-1 %>">后页 </asp:LinkButton><asp:LinkButton ID="cmdLastPage" runat="
16、;server"CommandArgument="Last" CommandName="Page"Enabled="<%#(GridView)Container.Parent.Parent).PageIndex!=(GridView)Container.Parent.Parent).PageCount-1 %>">尾页 </asp:LinkButton> <asp:TextBox ID="txtGoPage" runat="server&qu
17、ot;Text='<%#(GridView)Container.Parent.Parent).PageIndex+1 %>Width="32px"></asp:TextBox> 页<asp:Button ID="Button3" runat="server"OnClick="turn_Click" Text=" 转到 " /></PagerTemplate></asp:GridView><br /><br
18、 /><asp:Button ID="Button1" runat="server"OnClick="Button1Click" Text=" 增加 " /><br /></div></form></body></html>using System;using System.Collections.Generic;using System.Data;using System.Data.SqlClient;using System.Linq
19、;using System.Web;using System.Web.Configuration;using System.Web.UI;using System.Web.UI.WebControls;public partial class _Default : System.Web.UI.Page stringconStrWebConfigurationManager.ConnectionStrings"NorthwindConnectionString".ConnectionString;SqlConnection conn;SqlCommand cmd;protec
20、ted void Page_Load(object sender, EventArgs e) if (!IsPostBack)conn = new SqlConnection(conStr);conn.Open();cmd = new SqlCommand("select distinct Age from Information", conn); SqlDataReader dr = cmd.ExecuteReader();/DropDownList1 数据绑定DropDownList1.DataSource = dr;DropDownList1.DataTextFiel
21、d = "Age"DropDownList1.DataBind();dr.Dispose();conn.Dispose();ListItem li = new ListItem(" 全选择 ", "0");li.Selected = true;DropDownList1.Items.Add(li);String selectedValue = DropDownList1.SelectedValue;if (selectedValue = "0") bind();/ <summary>/ 绑定/ <
22、/summary>private void bind()String selectedValue = DropDownList1.SelectedValue;String sqlStr = String.Empty;if (selectedValue = "0")sqlStr = "Select * from Information"elsesqlStr = "Select * from Information where Age='" + selectedValue + "'" conn =
23、 new SqlConnection(conStr);SqlDataAdapter dr = new SqlDataAdapter(sqlStr, conn);DataSet ds = new DataSet();conn.Open();dr.Fill(ds, "Information");GridView1.DataSource = ds;GridView1.DataKeyNames = new string "Id" ;GridView1.DataBind();conn.Close();/ <summary>/ 查询/ </summ
24、ary>/ <param name="sender"></param>/ <param name="e"></param>protected void btnExecute_Click(object sender, EventArgs e)bind();/ <summary>/ 转到 zengjia 页/ </summary>/ <param name="sender"></param>/ <param name="e
25、"></param>protected void Button1_Click(object sender, EventArgs e)Response.Redirect("zengjia.aspx");/ <summary>/ 取消编辑/ </summary>/ <param name="sender"></param>/ <param name="e"></param>protected void GridView1_RowCancel
26、ingEdit(object sender, GridViewCancelEditEventArgs e) GridView1.EditIndex = -1;bind();/ <summary>/ 编辑/ </summary>/ <param name="sender"></param>/ <param name="e"></param>protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e
27、)GridView1.EditIndex = e.NewEditIndex;bind();/ <summary>/ 更新/ </summary>/ <param name="sender"></param>/ <param name="e"></param>protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)TextBox text1 = (TextBox)(GridView1.R
28、owse.RowIndex.Cells1.Controls0);TextBox text2 = (TextBox)(GridView1.Rowse.RowIndex.Cells2.Controls0);TextBox text3 = (TextBox)(GridView1.Rowse.RowIndex.Cells3.Controls0);TextBox text4 = (TextBox)(GridView1.Rowse.RowIndex.Cells4.Controls0);if (string.IsNullOrEmpty(text1.Text)Response.Write("<
29、script>alert(' 请输入姓名');</script>");return;if (string.IsNullOrEmpty(text2.Text) Response.Write("<script>alert(' 请输入年龄')</script>");return; else try int tmp = int.Parse(text2.Text);catch (Exception) Response.Write("<script>alert(' 请输入年
30、龄')</script>");return; if (string.IsNullOrEmpty(text3.Text) Response.Write("<script>alert(' 请输入地址')</script>");return; if (string.IsNullOrEmpty(text4.Text) Response.Write("<script>alert(' 请输入电话号码')</script>");return; else if
31、(text4.Text.Length < 11 | text4.Text.Length > 11 | text4.Text0 = 0) Response.Write("<script>alert(' 请输入电话号码')</script>");return; elsetryInt64 tmp = Int64.Parse(text4.Text); catch (Exception) Response.Write("<script>alert(' 请输入电话号码')</script&g
32、t;");return;tryAgeerintConvert.ToInt32(TextBox)(GridView1.Rowse.RowIndex.Cells2.Controls0).Text.ToString().Trim ();conn = new SqlConnection(conStr); string sqlstr = "update Information set Name='" +(TextBox)(GridView1.Rowse.RowIndex.Cells1.Controls0).Text.ToString().Trim()+"&
33、#39;,Age='"+(TextBox)(GridView1.Rowse.RowIndex.Cells2.Controls0).Text.ToString().Trim()+"',Address='"+(TextBox)(GridView1.Rowse.RowIndex.Cells3.Controls0).Text.ToString().Trim()+"',Phone='"+(TextBox)(GridView1.Rowse.RowIndex.Cells4.Controls0).Text.ToStrin
34、g().Trim()+"'whereId='"+(GridView1.Rowse.RowIndex.Cells0).Text.ToString().Trim() + "'" cmd = new SqlCommand(sqlstr, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); GridView1.EditIndex = -1; bind(); catch return; / 通过跳转页面传递数据Id 更新数据/conn = new SqlConnection(co
35、nStr);/ string id = "select Id from Id where Id='"+(GridView1.Rowse.RowIndex.Cells0).Text.ToString().Trim() + "'"/Response.Redirect("zengjia.aspx?id='"+(GridView1.Rowse.RowIndex.Cells0).Text.ToString().Trim() + "'");/ <summary>/ 删除/ </
36、summary> / <param name="sender"></param> / <param name="e"></param> protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) conn=new SqlConnection(conStr);string sqlstr="delete from Information where id='"+ (GridView
37、1.Rowse.RowIndex.Cells0).Text.ToString().TrimO+""'cmd = new SqlCommand(sqlstr, conn);conn.Open();cmd.ExecuteNonQuery();conn.Close();GridView1.EditIndex = -1; bind(); / <summary> /分页 / </summary> / <param name="sender"></param> / <param name="e&
38、quot;></param> protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) GridView1.PageIndex = e.NewPageIndex; bind();/ <summary>/跳转 / </summary> / <param name="sender"></param> / <param name="e"></param>protec
39、ted void turn_Click(object sender, EventArgs e) GridView1.PageIndex=int.Parse(TextBox)GridView1.BottomPagerRow.FindControl("txtGoPage").Text) - 1; bind(); <% Page Language="C#" AutoEventWireup="true" CodeFile="zengjia.aspx.cs Inherits="zengjia" %>&l
40、t;!DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server"><meta http -equiv="Content -Type" content="text/html; charset=utf -8"/><title></title><script type="text/javascript"></script>
41、</head><body><form id="form1" runat="server"><div><br /><asp:Label ID="Label1" runat="server" Text="姓名:"></asp:Label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><
42、;br /><asp:Label ID="Label2" runat="server" Text="年龄:"></asp:Label><asp:TextBoxID="TextBox2"runat="server"ValidateRequestMode="Enabled" ></asp:TextBox><br /><asp:Label ID="Label3" runat="se
43、rver" Text="地址:"></asp:Label><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br /><asp:Label ID="Label4" runat="server" Text="电话:"></asp:Label><asp:TextBox ID="TextBox4" run
44、at="server" ></asp:TextBox><br /><asp:Button ID="Button1" runat="server" Text="保存"OnClick="Button1_Click" style="height: 21px" /><asp:Button ID="Button2" runat="server" OnClick="Button2_Click
45、" Text=" 返回"/></div></form></body></html> using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;using System.Web.Configuration;using
46、System.Text.RegularExpressions;public partial class zengjia : System.Web.UI.Page stringconStr=WebConfigurationManager.ConnectionStrings"NorthwindConnectionString".ConnectionString; protected void Page_Load(object sender, EventArgs e) /接收传递过来的数据Id查询数据绑定到textbox上再进行更新/if (!IsPostBack) /if (R
47、equest.QueryString"id" != null)/Button1.Text ="更新";/SqlConnectionconn= new SqlConnection(conStr);/SqlCommandcmd= newSqlCommand("select*from Information whereId=" + Request.QueryString"id"+"", conn);/conn.Open();/SqlDataReader dr =cmd.ExecuteReader(Co
48、mmandBehavior.CloseConnection);/while(dr.Read()/this.TextBox1.Text = dr"Name".ToString();/this.TextBox2.Text = dr"Age".ToString();/this.TextBox3.Text = dr"Address".ToString();/this.TextBox4.Text = dr"Phone".ToString();/ <summary>/ 增加/ </summary>/ &
49、lt;param name="sender"></param>/ <param name="e"></param>protected void Button1_Click(object sender, EventArgs e)/ 判断用户输入if (string.IsNullOrEmpty(TextBox1.Text)Response.Write("<script>alert(' 请输入姓名')</script>");return;if (string.
50、IsNullOrEmpty(TextBox2.Text)Response.Write("<script>alert(' 请输入年龄')</script>");return; elsetryint tmp = int.Parse(TextBox2.Text);catch (Exception)Response.Write("<script>alert(' 请输入年龄')</script>");return; if (string.IsNullOrEmpty(TextBox3.Text)Response.Write("<script>alert(' 请输入地址')</script>");return;if (string.IsNullOrEmpty(TextBox4.Text)Respons
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2022年内蒙古省公务员录用考试《行测》真题及答案解析
- 吉林师范大学《时间序列分析》2021-2022学年第一学期期末试卷
- 吉林师范大学《酒店管理》2021-2022学年第一学期期末试卷
- 外墙真石漆工程验收标准方案
- 服装生产商售后跟踪方案
- 吉林师范大学《法学论文写作训练》2021-2022学年期末试卷
- 山东商品房买卖合同的风险防范措施
- 吉林大学《物联网技术与应用》2021-2022学年期末试卷
- 2024简单的保姆用工合同
- 2024家居购货合同范文
- 人行道铺砖施工方案
- 利用java实现TFTP协议
- 药剂学药物动力学考点归纳
- 中心城排水管网改造三期工程有限空间作业专项方案
- 要事第一(课堂PPT)
- SDR特别提款权PPT课件
- SH/T3903-石油化工建设工程项目监理规范(承包单位用表)
- 建筑垃圾综合处理厂项目可行性研究报告(完整版)
- 《职工基本养老保险缴费流水情况范本表格》
- 医院临床带教指导教师考核细则(完整版)
- 防静电检测方法
评论
0/150
提交评论