请问如何实现,代码如下:using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open(); if (DropDownList1.SelectedItem.Text == "姓名")
{
string strsql = "Select * from b_gradinfo where Name= '" + this.TextBox1.Text + "'";
//DataSet ds = new DataSet();
db sdb = new db();
DataSet ds = sdb.sqldb(strsql); Session["sqlinfo"] = Convert.ToString(strsql);
DataList1.DataSource = ds;
DataList1.DataBind(); }
else
{
string strsql = "Select * from b_gradinfo where CertiCode= '" + this.TextBox1.Text + "'"; db sdb = new db();
DataSet ds = sdb.sqldb(strsql);
Session["sqlinfo"] = Convert.ToString(strsql);
DataList1.DataSource = ds;
DataList1.DataBind();
} }
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "Select * from b_gradinfo where";
if (DropDownList4.SelectedItem.Text != "")
{
strsql += " Major='" + DropDownList4.SelectedItem.Text + "'";
} if (DropDownList5.SelectedItem.Text != "")
{
strsql += " and LanLevel='" + DropDownList5.SelectedItem.Text + "'";
} if (DropDownList6.SelectedItem.Text != "")
{
strsql += " and RecordSchool='" + DropDownList6.SelectedItem.Text + "'";
} if (DropDownList7.SelectedItem.Text != "")
{
strsql += " and Sex='" + DropDownList7.SelectedItem.Value + "'";
} if (DropDownList9.SelectedItem.Text != "")
{
strsql += " and ComputerLevel='" + DropDownList9.SelectedItem.Value + "'";
} if (DropDownList10.SelectedItem.Text != "")
{
strsql += " and Polities='" + DropDownList10.SelectedItem.Text + "'";
} if (DropDownList12.SelectedItem.Text != "")
{
strsql += " and Married='" + DropDownList12.SelectedItem.Value + "'";
}
Session["sqlinfo"] = Convert.ToString(strsql);
db spds = new db();
DataList1.DataSource = spds.pds(strsql); DataList1.DataBind(); }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{ db spds2 = new db();
string strsql = Session["sqlinfo"].ToString(); int n = spds2.pds(strsql).PageCount;//将分页总数赋给变量n
int i = spds2.pds(strsql).CurrentPageIndex;//将当前分页码赋给i Label lblpc = (Label)e.Item.FindControl("lblpc");
lblpc.Text = n.ToString();
Label lblp = (Label)e.Item.FindControl("lblp");
lblp.Text = Convert.ToString(spds2.pds(strsql).CurrentPageIndex + 1);
HyperLink hlfir = (HyperLink)e.Item.FindControl("hlfir");
hlfir.NavigateUrl = "?page=0";
HyperLink hlla = (HyperLink)e.Item.FindControl("hlla");
hlla.NavigateUrl = "?page=" + Convert.ToInt32(n - 1);
HyperLink hlp = (HyperLink)e.Item.FindControl("hlp");
HyperLink hln = (HyperLink)e.Item.FindControl("hln"); if (i <= 0)
{//如果当前页已经是第0页
hlp.Enabled = false;
hlfir.Enabled = false;
hln.Enabled = true;
}
else
{
hlp.NavigateUrl = "?page=" + Convert.ToInt32(i - 1);
}
if (i > n - 2)
{//如果当前项已经是最末页
hln.Enabled = false;
hlla.Enabled = false;
hlp.Enabled = true;
}
else
{
hln.NavigateUrl = "?page=" + Convert.ToInt32(i + 1);
} //跳转分页
int pageall = spds2.pds(strsql).PageCount;
DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
DropDownList1.Items.Clear();
for (int m = 1; m <= pageall; m++)
{
ListItem myli = new ListItem(m.ToString(), m.ToString());
myli.Enabled = true;
DropDownList1.Items.Add(myli);
}
DropDownList1.Enabled = true;
DropDownList1.AutoPostBack = true; if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString() != "")
{
DropDownList1.SelectedValue = Convert.ToString(int.Parse(Request.QueryString["page"].ToString()) + 1); ;
} } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string i = ((DropDownList)(sender)).SelectedValue;
Int32 m = Convert.ToInt32(i); Response.Redirect(Request.Path + "?page=" + (m - 1));
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open(); if (DropDownList1.SelectedItem.Text == "姓名")
{
string strsql = "Select * from b_gradinfo where Name= '" + this.TextBox1.Text + "'";
//DataSet ds = new DataSet();
db sdb = new db();
DataSet ds = sdb.sqldb(strsql); Session["sqlinfo"] = Convert.ToString(strsql);
DataList1.DataSource = ds;
DataList1.DataBind(); }
else
{
string strsql = "Select * from b_gradinfo where CertiCode= '" + this.TextBox1.Text + "'"; db sdb = new db();
DataSet ds = sdb.sqldb(strsql);
Session["sqlinfo"] = Convert.ToString(strsql);
DataList1.DataSource = ds;
DataList1.DataBind();
} }
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "Select * from b_gradinfo where";
if (DropDownList4.SelectedItem.Text != "")
{
strsql += " Major='" + DropDownList4.SelectedItem.Text + "'";
} if (DropDownList5.SelectedItem.Text != "")
{
strsql += " and LanLevel='" + DropDownList5.SelectedItem.Text + "'";
} if (DropDownList6.SelectedItem.Text != "")
{
strsql += " and RecordSchool='" + DropDownList6.SelectedItem.Text + "'";
} if (DropDownList7.SelectedItem.Text != "")
{
strsql += " and Sex='" + DropDownList7.SelectedItem.Value + "'";
} if (DropDownList9.SelectedItem.Text != "")
{
strsql += " and ComputerLevel='" + DropDownList9.SelectedItem.Value + "'";
} if (DropDownList10.SelectedItem.Text != "")
{
strsql += " and Polities='" + DropDownList10.SelectedItem.Text + "'";
} if (DropDownList12.SelectedItem.Text != "")
{
strsql += " and Married='" + DropDownList12.SelectedItem.Value + "'";
}
Session["sqlinfo"] = Convert.ToString(strsql);
db spds = new db();
DataList1.DataSource = spds.pds(strsql); DataList1.DataBind(); }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{ db spds2 = new db();
string strsql = Session["sqlinfo"].ToString(); int n = spds2.pds(strsql).PageCount;//将分页总数赋给变量n
int i = spds2.pds(strsql).CurrentPageIndex;//将当前分页码赋给i Label lblpc = (Label)e.Item.FindControl("lblpc");
lblpc.Text = n.ToString();
Label lblp = (Label)e.Item.FindControl("lblp");
lblp.Text = Convert.ToString(spds2.pds(strsql).CurrentPageIndex + 1);
HyperLink hlfir = (HyperLink)e.Item.FindControl("hlfir");
hlfir.NavigateUrl = "?page=0";
HyperLink hlla = (HyperLink)e.Item.FindControl("hlla");
hlla.NavigateUrl = "?page=" + Convert.ToInt32(n - 1);
HyperLink hlp = (HyperLink)e.Item.FindControl("hlp");
HyperLink hln = (HyperLink)e.Item.FindControl("hln"); if (i <= 0)
{//如果当前页已经是第0页
hlp.Enabled = false;
hlfir.Enabled = false;
hln.Enabled = true;
}
else
{
hlp.NavigateUrl = "?page=" + Convert.ToInt32(i - 1);
}
if (i > n - 2)
{//如果当前项已经是最末页
hln.Enabled = false;
hlla.Enabled = false;
hlp.Enabled = true;
}
else
{
hln.NavigateUrl = "?page=" + Convert.ToInt32(i + 1);
} //跳转分页
int pageall = spds2.pds(strsql).PageCount;
DropDownList DropDownList1 = (DropDownList)e.Item.FindControl("DropDownList1");
DropDownList1.Items.Clear();
for (int m = 1; m <= pageall; m++)
{
ListItem myli = new ListItem(m.ToString(), m.ToString());
myli.Enabled = true;
DropDownList1.Items.Add(myli);
}
DropDownList1.Enabled = true;
DropDownList1.AutoPostBack = true; if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString() != "")
{
DropDownList1.SelectedValue = Convert.ToString(int.Parse(Request.QueryString["page"].ToString()) + 1); ;
} } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string i = ((DropDownList)(sender)).SelectedValue;
Int32 m = Convert.ToInt32(i); Response.Redirect(Request.Path + "?page=" + (m - 1));
}
}
解决方案 »
- 网站发布到服务器上后访问提示数据库是只读的是怎么回事?
- 请教大家这段代码哪里有问题啊?
- ProfileProvider重载后的使用方法
- MasterPage和框架
- 通过web services 返回两个Dataset,字段名一样但宽度不一样,想将它们合并成一个dataset,请指点
- 怎样实现在用户控件内点击搜索按钮时,在DataGrid中显示相应的数据?急症!!!
- IBuySpy安装失败!!请大家帮忙
- .net的就是好,支持微软!
- ajax toolkit问题,显示不了效果,求助
- 如何处理编码的问题
- 后台提交页面后无法获取返回数据求解!烦请过去帮忙看下可否?
- 在 ASP.NET web 应用程序中如何添加 System.Web.UI.WebControls 引用。
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;/// <summary>
/// db 的摘要说明
/// </summary>
public class db
{
protected string connstring;
private int pagesize;
public db()
{
connstring = ConfigurationManager.ConnectionStrings["gradinfoConnectionString"].ConnectionString;
pagesize = 1;
}
public static SqlConnection CreateConnection()
{
SqlConnection connstring = new SqlConnection(ConfigurationManager.ConnectionStrings["gradinfoConnectionString"].ConnectionString);
return connstring;
}
public DataTable dt(string query)
{
SqlConnection con = new SqlConnection(connstring);
SqlDataAdapter sda = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
sda.Fill(ds, "gradinfo");
return ds.Tables["gradinfo"];
}
///// <summary>
///// 根据一个传来的整数作为当前页码并返回分页后的数据员
///// </summary>
public PagedDataSource pds(int pg,string strsql)
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt(strsql).DefaultView;
pds.AllowPaging = true;
pds.PageSize = pagesize;
pds.CurrentPageIndex = pg;
return pds;
}
public PagedDataSource pds(string strsql)
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt(strsql).DefaultView;
pds.AllowPaging = true;
pds.PageSize = pagesize;
//pds.CurrentPageIndex = pg;
return pds;
}
/// <summary>
/// 根据SQL查询语句返回一个表示该SQL语句影响行数的整数,
/// </summary>
public int sql(string query)
{
SqlConnection con = new SqlConnection(connstring);
con.Open();
SqlCommand cmd = new SqlCommand(query, con);
return cmd.ExecuteNonQuery();
} public DataSet sqldb(string query)
{
SqlConnection con = new SqlConnection(connstring);
con.Open(); SqlDataAdapter ada = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
ada.Fill(ds, "gradinfo");
return ds;
} public DataView dv(string query)
{
SqlConnection con = new SqlConnection(connstring);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand(query, con);
DataSet ds = new DataSet();
sda.Fill(ds, "gradinfo");
return ds.Tables["gradinfo"].DefaultView;
}
}
http://topic.csdn.net/u/20080331/13/b8a84332-fb85-424e-8f87-63a3c15006a3.html 参考下
{
//根据页码显示数据.
}在
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string i = ((DropDownList)(sender)).SelectedValue;
Int32 m = Convert.ToInt32(i); BindDataList(m);
}hyperlink也是一样.
第一阶段教学内容安排(200课时)
课程名称 课程内容 培训目的
C# 编程方法和编程技巧、面向对象的思想、数据结构和算法以及设计模式(120课时) 详细介绍.Net Framework、C# 语法、编程方法、编程技巧。深入理解和学习面向对象的思想和方法,学会用面向对象的方法去认识问题、分析问题和解决问题,学习数据结构和常用算法,学习MVC模式、单件模式、适配器模式、工厂模式、观察者模式等设计模式。 深入了解.Net FrameWork、掌握C#语法、编程方法和编程技巧,掌握数据结构、常用算法和面向对象的思想。
针对循环、数组、类的概念、类的构建、类的使用、对象的创建、面向对象的思想、集合、常用算法、IO操作、泛型、反射、委托、迭代器等知识点先后完成如下项目:1。通讯录系统;2。列车售票系统;3。教学管理系统。 通过实际项目深入理解和掌握C# 编程、面向对象的思想、类的概念和使用、对象的创建、算法、IO操作等
数据库知识和 SQL Server 2000 (40课时) 讲授数据库的基本知识和SQL Server 2000, 讲授数据库的设计和优化,学习T-SQL 和数据库编程,学习存储过程(stored procedure)、触发机制(trigger)和索引(index). 掌握 SQL Server 2000, 学会数据库编程, 掌握T-SQL, Stored Procedure, Trigger, index.
C# 高级编程I
(40课时) 系统地讲授多线程的基本概念和使用、线程的设计、线程的优先级;讲授共享程序集(公有程序集)、私有程序集的组成、原理和使用;学习反射(Reflection)、属性(Attribute)的相关概念和使用。学习流(stream)的概念和IO操作、文件的读写和传输。 掌握多线程编程、流的概念、文件的操作和程序集的相关概念,学习反射和属性以及动态定义类型和方法。
第二阶段教学内容安排(400课时)
课程名称 课程内容 培训目的
ASP.Net2.0、ADO.Net2.0和Web 应用程序
(160课时) 系统讲授 ASP.Net2.0、ADO.Net2.0、 基于数据库的WEB应用程序的开发;讲授母版页、Web Part技术、站点导航、数据元对象、Asp.Net缓冲技术、和Asp.Net的安全机制;讲授用户控件和第三方控件的开发和使用;讲授Web Service及其应用和相关的安全性问题、WSE、SOAP、WSDL、UDDI、Windows Service、VSS(Visual Source Safe)。学习HTML、XML、JavaScript、水晶报表(Crystal Report)和IIS 基础以及WEB应用程序性能优化;学习Ajax、Web2.0的相关技术。
熟练掌握基于数据库的Web应用程序和Web服务的开发技术;掌握第三方控件技术和报表技术;掌握Ajax、Web2.0技术;学会操作和处理XML,等等.
针对ASP.Net2.0、ADO.Net2.0、Web服务、HTML、XML、JavaScript、水晶报表(Crystal Report)、Ajax、Web2.0等知识点先后完成如下项目:1。基于Web的远程文件管理系统(Remote File Management System);2。在线咨询系统;3。论坛系统 通过实际项目深入理解和掌握Web开发技术,包括:Asp.Net、Ajax、XML、 Ado.Net、Web Service、Crystal Report 等。
Windows 应用程序、设计模式和Oracle数据库编程(40课时) 系统地讲授Windows应用程序的开发,学习观察者模式和Oracle数据库编程。 熟练开发基于数据库的Windows应用程序,掌握Oracle数据库编程。
C# 高级编程II
(40课时) 详细讲授DNS开发、套接字(Socket)编程、TCP、UDP 编程、消息队列(MSMQ)及其编程;详细讲授远程处理(Remoting)技术,包括基本远程处理框架,配置文件及其应用, 异步远程处理技术,租约和生存期控制;系统地讲授Windows服务编程、Com+ 服务、WSE2.0的使用。进一步讲解进程、线程和应用程序域,讲解多线程的使用、临界区域的概念、序列化、属性和反射技术。深入学习InterNet Access 技术和正则表达式技术。 掌握 Socket 编程、TCP、 UDP编程、远程处理(Remoting)技术、Windows服务编程;Com+ 服务、WSE2.0、InterNet Access和正则表达式技术等。
OOAD&UML
(24课时) 讲授面向对象的分析设计方法、UML 语法及Rational Rose/MS Visio 工具的使用 和VSS的使用。 掌握面向对象的建模、分析、设计和实施方法.学习UML 建模语言和 Rational Rose /MS Visio 建模工具.
项目实习
(120课时) 在培训老师的指导下完成如下项目:
(1) 基于套接字(Socket)的 C/S 结构的在线咨询系统。
(2) 基于Windows Form和正则表达式技术的职位搜索器。
(3) 电子商务软件项目:” Prepaid Phone Card Online Sales System”。内容包括:Application Architecture Analysis、Creating the Data Model、Design Database Schema、Programming Stored procedures、Web Application Design、App Setting、 Log in Design、 Security、 Authentication、Authorization、 Navigation Bar、Shopping Cart、Cross-Brower Support、Performance.
通过实际项目, 培养学生实战能力,包括系统分析、设计(包括功能需求分析、数据库设计、功能模块设计和详细设计)、开发、调试、测试和部署的能力。 需要这个培训视频的朋友请联系 QQ 9 3 6 6 5 2 1 1 4
{
#region 数据绑定及显示
int recordAmount = 0, pageAmount = 0;
BoardName();
DataTable table;
table =SqlPage(...);
this.List_.DataSource = table;
this.List_.DataBind(); if (requestPage > pageAmount)
requestPage = pageAmount;
if (pageAmount != 1)
{
this.LinkButton_Next.Enabled = true;
this.LinkButton_Up.Enabled = true;
this.LinkButton_First.Enabled = true;
this.LinkButton_Last.Enabled = true;
}
if (requestPage == 1)
{
this.LinkButton_First.Enabled = false;
this.LinkButton_Up.Enabled = false;
}
if (requestPage == pageAmount)
{
this.LinkButton_Next.Enabled = false;
this.LinkButton_Last.Enabled = false;
}
topicamount = recordAmount.ToString();
this.Text_CurrentPage.Text = requestPage.ToString();
this.Text_PageCount.Text = pageAmount.ToString();
this.Label_Detail.Text = "页次<font color=\"red\">" + requestPage + "</font>/<font color=\"red\">" + pageAmount + "</font> 每页<font color=\"red\">30</font>条 共<font color=\"red\">" + recordAmount + "</font>条记录";
#endregion
}
protected void LinkButton_Up_Click(object sender, EventArgs e)
{
#region 上一页
this.LinkButton_Next.Enabled = true;
int pageCurrent = int.Parse(this.Text_CurrentPage.Text);
int PageAmount = int.Parse(this.Text_PageCount.Text);
if (pageCurrent > PageAmount && PageAmount != -1)
pageCurrent = PageAmount;
ShowPage(pageCurrent - 1, ReturnWhere());
#endregion
} protected void LinkButton_Down_Click(object sender, EventArgs e)
{
#region 下一页
this.LinkButton_Up.Enabled = true;
this.LinkButton_First.Enabled = true;
int pageCurrent = int.Parse(this.Text_CurrentPage.Text);
int PageAmount = int.Parse(this.Text_PageCount.Text);
if (pageCurrent > PageAmount && PageAmount != -1)
pageCurrent = PageAmount;
ShowPage(pageCurrent + 1, ReturnWhere());
#endregion
}
protected void LinkButton_First_Click(object sender, EventArgs e)
{
#region 首页
this.LinkButton_First.Enabled = false;
this.LinkButton_Up.Enabled = false;
ShowPage(1, ReturnWhere());
#endregion
} protected void LinkButton_Last_Click(object sender, EventArgs e)
{
#region 尾页
this.LinkButton_Last.Enabled = false;
this.LinkButton_Next.Enabled = false;
int PageAmount = int.Parse(this.Text_PageCount.Text);
ShowPage(PageAmount, ReturnWhere());
#endregion
}
public static DataTable SqlPage(string tableName, string tableId, string field, string order, string where, int pageCurrent, int pageSize, ref int recordAmount, ref int pageAmount)
{
DataTable table = new DataTable();
SqlConnection SqlConn = new SqlConnection(connection);
SqlConn.Open();
SqlCommand comm = new SqlCommand("page", SqlConn);
comm.CommandType = System.Data.CommandType.StoredProcedure;
comm.Parameters.Add("@tbname", SqlDbType.NVarChar, 4000).Value = tableName;
comm.Parameters.Add("@FieldKey", SqlDbType.NVarChar, 4000).Value = tableId;
comm.Parameters.Add("@PageCurrent", SqlDbType.Int).Value = pageCurrent;
comm.Parameters.Add("@PageSize", SqlDbType.Int).Value = pageSize;
comm.Parameters.Add("@FieldShow", SqlDbType.NVarChar, 1000).Value = field;
comm.Parameters.Add("@FieldOrder", SqlDbType.NVarChar, 1000).Value = order;
comm.Parameters.Add("@Where", SqlDbType.NVarChar, 1000).Value = where;
comm.Parameters.Add("@PageCount", SqlDbType.Int).Direction = ParameterDirection.Output;
comm.Parameters.Add("@RecordCount", SqlDbType.Int).Direction = ParameterDirection.Output;
SqlDataAdapter data = new SqlDataAdapter(comm);
data.Fill(table);
data.Dispose();
SqlConn.Close();
recordAmount = (int)comm.Parameters["@RecordCount"].Value;
pageAmount = (int)comm.Parameters["@PageCount"].Value;
comm.Dispose();
return table;
}