conn.Open();
sql = \; SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); da.Fill(ds);
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0) {
PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true; pds.PageSize = 10; int curPage;
if (Request.QueryString[\] != null) {
curPage = Convert.ToInt32(Request.QueryString[\]); } else {
curPage = 1; }
pds.CurrentPageIndex = curPage - 1; this.Repeater1.DataSource = pds; this.Repeater1.DataBind();
this.Label1.Text += \共有\ + ds.Tables[0].Rows.Count.ToString() + \条记录 \;
this.Label1.Text += \每页显示\ + pds.PageSize + \条 \;
this.Label1.Text += \共\ + pds.PageCount.ToString() + \页 \;
this.Label1.Text += \当前第\ + curPage.ToString() + \页 \;
if (curPage == 1) {
this.Label1.Text += \首页 \; this.Label1.Text += \上一页 \; }
19
else {
this.Label1.Text += \首页 \; this.Label1.Text += \ + (curPage - 1).ToString() + \上一页 \; }
if (curPage == pds.PageCount) {
this.Label1.Text += \下一页 \; this.Label1.Text += \尾页 \; } else {
this.Label1.Text += \ + (curPage + 1).ToString() + \下一页 \;
this.Label1.Text += \href='uTeacherManage.aspx?page=\ + pds.PageCount.ToString() + \尾页 \; }
string HtmlSelectString = \onchange=\\\; for (int i = 1; i <= pds.PageCount; i++) {
if (i == curPage) {
HtmlSelectString += \ + i + \第\ + i + \页\; } else {
HtmlSelectString += \ + i + \第\ + i + \页\; } }
HtmlSelectString += \;
this.Label1.Text += \ + HtmlSelectString + \; } else {
this.Label1.Text = \当前没有记录\; }
ds.Dispose(); da.Dispose();
20
conn.Close(); conn.Dispose(); }
protected void Button1_Click(object sender, EventArgs e) {
if (txtKey.Text == \) //查询 {
string sqlnn = \; sqloperate.dlRepeterBind(Repeater1, sqlnn);
} else {
string sqlnn = \ + ddlCondition.SelectedValue + \'%\ + txtKey.Text.Trim() + \;
sqloperate.dlRepeterBind(Repeater1, sqlnn); } }
protected void txtKey_TextChanged(object sender, EventArgs e) { }
protected void Button3_Click(object sender, EventArgs e) {
Export(\, \教师个人信息表.doc\); }
private void Export(string FileType, string FileName) {
Response.AppendHeader(\, \ +
21
HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString()); Response.ContentType = FileType; this.EnableViewState = false;
StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); Repeater1.RenderControl(hw); Response.Write(tw.ToString()); Response.End(); }
public override void VerifyRenderingInServerForm(Control control) { }
protected void Button4_Click(object sender, EventArgs e) {
Export1(\, \教师信息报表.xls\); }
private void Export1(string FileType, string FileName) {
Response.Charset = \;
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader(\, \ + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString()); Response.ContentType = FileType; this.EnableViewState = false;
StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); Repeater1.RenderControl(hw); Response.Write(tw.ToString()); Response.End(); } }
22
string sql;
protected void Page_Load(object sender, EventArgs e) {
if (!this.IsPostBack) {
if (Request.QueryString[\] == \) {
zp_txt();
}
else if (Request.QueryString[\] == \) {
del_zp(); }
} }
public void zp_txt()//显示文本信息 {
int ID = int.Parse(Request.QueryString[\]); sql = \ + ID; DataTable dt = Class1.ExecSel(sql);
TextBox1.Text = Convert.ToString(dt.Rows[0][\]); TextBox2.Text = Convert.ToString(dt.Rows[0][\]);
23