GridView自定义分页导航
导读:
自己做的一个项目中所运用到的技术:|
1. 日历控件(带时分秒)
2. GridView 批量删除,自定义分页,定位页码
3. GridView 修改
4. GridView 鼠标经过改变行的颜色
效果如下:
HTML:
CS:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 StfCmpManager : System.Web.UI.Page
...{
protected void Page_Load(object sender, System.EventArgs e)
...{
string StfRight = ""
// 在此处放置用户代码以初始化页面
if (Session["UserId"] == null)
...{
Response.Write("");
return
}
else
...{
StfRight = Session["UserRight"].ToString().Trim();
if (!this.IsPostBack)
...{
if (StfRight != "7" && StfRight != "8")
...{
Response.Write("");
return
}
GridViewBind("");
}
}
}
private void GridViewBind(string Sqlsort)
...{
string where = string.Empty;
where = "and a.StfRight='6' and a.StfId=b.Stfid"
if (TStfName.Text.Trim() != "")
...{
where += " and a.StfCmpName like '%" + TStfName.Text.Trim() + "%'"
}
if (StartTime.Text.Trim() != "")
...{
where += " and a.StfRegistertime >= '" + StartTime.Text + "'"
}
if (EndTime.Text.Trim() != "")
...{
where += " and a.StfRegistertime <= '" + EndTime.Text + "'"
}
if (where != string.Empty)
...{
where = "Where " + where.Substring(4);
}
string connStr = ConfigurationManager.AppSettings.Get("DataConnectionString");
string SqlStr = "Select a.StfId as StfId,a.StfName as StfName,a.StfRealName as StfRealName,a.StfCmpName as StfCmpName,b.StfCmpMoney as StfCmpMoney,b.StfQbmoney as StfQbmoney,a.StfRegistertime as StfRegistertime From TStafferInfo a,TCmpMoney b " + where + Sqlsort;
//Response.Write(SqlStr);
//Response.End();
DataSet ds = new DataSet();
try
...{
SqlConnection conn = new SqlConnection(connStr);
if (conn.State.ToString() == "Closed") conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
da.Fill(ds, "TStafferInfo");
if (conn.State.ToString() == "Open") conn.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
LblCurrentIndex.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页"
LblPageCount.Text = "共 " + GridView1.PageCount.ToString() + " 页"
LblRecordCount.Text = "总共 " + ds.Tables[0].Rows.Count.ToString() + " 条"
if (ds.Tables[0].Rows.Count == 0)
...{
btnFirst.Visible = false
btnPrev.Visible = false
btnNext.Visible = false
btnLast.Visible = false
LblCurrentIndex.Visible = false
LblPageCount.Visible = false
LblRecordCount.Visible = false
}
else if (GridView1.PageCount == 1)
...{
btnFirst.Visible = false
btnPrev.Visible = false
btnNext.Visible = false
btnLast.Visible = false
}
// 计算生成分页页码,分别为:"首 页" "上一页" "下一页" "尾 页"
btnFirst.CommandName = "1"
btnPrev.CommandName = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString());
btnNext.CommandName = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2).ToString());
btnLast.CommandName = GridView1.PageCount.ToString();
//
this.ddlCurrentPage.Items.Clear();
for (int i = 1 i <= this.GridView1.PageCount; i++)
...{
this.ddlCurrentPage.Items.Add(i.ToString());
}
this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
}
catch (Exception ex)
...{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
protected void PagerButtonClick(object sender, EventArgs e)
...{
GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1
GridViewBind("");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
...{
e.Row.Attributes["onmouseover"] = "ItemOver(this)"
}
protected void Button1_Click(object sender, EventArgs e)
...{
Response.Write(Request.Form.Get("RadioName"));
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
...{
string sql = ""
if (ViewState["DataConnectionString"] == null || ViewState["DataConnectionString"].ToString().CompareTo("") == 0)
...{
ViewState["DataConnectionString"] = " desc"
}
else
ViewState["DataConnectionString"] = ""
sql = " order by " + e.SortExpression + ViewState["DataConnectionString"];
GridViewBind(sql);
//DataFormatString="{0:yyyy年MM月dd日 hh时mm分ss秒}"
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
...{
this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
GridViewBind("");
}
private bool CheckAddClientInfoForm()
...{
int Tag = 0
if (Tag == 1)
...{
Response.Write("");
return false
}
else
...{
return true
}
}
public string GetClientVisitInfoShowAnchorStr(object StfId, object StfName)
...{
string AnchorStr = "
return AnchorStr;
}
public string GetClientVisitInfoShowCmpMoney(object StfId, object StfName)
...{
string AnchorStr = "
return AnchorStr;
}
protected void Button3_Click(object sender, EventArgs e)
...{
string str = ""
string[] ckb = null
str = Request.Form.Get("checkboxname");
ckb = str.Split(new char[] ...{ ',' });
for (int i = 0 i < ckb.Length; i++)
...{ //帐户和信息同时删除
string StrSql = " Delete TStafferInfo where StfId ='" + ckb[i] + "'"
String StrSql_d = " Delete TCmpMoneyInfo where StfId ='" + ckb[i] + "'"
SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("DataConnectionString"));
SqlCommand Cmd = new System.Data.SqlClient.SqlCommand(StrSql, Conn);
SqlCommand Cmd_d = new System.Data.SqlClient.SqlCommand(StrSql_d, Conn);
Conn.Open();
SqlTransaction Trans = Conn.BeginTransaction();
try
...{
Cmd.Transaction = Trans;
Cmd_d.Transaction = Trans;
Cmd.ExecuteNonQuery();
Cmd_d.ExecuteNonQuery();
Trans.Commit();
}
catch (Exception Err)
...{
Trans.Rollback();
Response.Write(Err.Message);
}
}
Response.Write("?);>
GridViewBind("");
}
protected void SelectClient_Click(object sender, EventArgs e)
...{
GridViewBind("");
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1511765
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1520093
本文转自
http://blog.csdn.net/heker2007/archive/2007/03/04/1520093.aspx
自己做的一个项目中所运用到的技术:|
1. 日历控件(带时分秒)
2. GridView 批量删除,自定义分页,定位页码
3. GridView 修改
4. GridView 鼠标经过改变行的颜色
效果如下:
![](http://p.blog.csdn.net/images/p_blog_csdn_net/mengyao/f065610dc7064075b8f83ce87ba68dfe.png)
HTML:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CS:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Configuration;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.Security;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls.WebParts;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data.SqlClient;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
public partial class StfCmpManager : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string StfRight = ""
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (Session["UserId"] == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StfRight = Session["UserRight"].ToString().Trim();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (!this.IsPostBack)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (StfRight != "7" && StfRight != "8")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void GridViewBind(string Sqlsort)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string where = string.Empty;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
where = "and a.StfRight='6' and a.StfId=b.Stfid"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (TStfName.Text.Trim() != "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
where += " and a.StfCmpName like '%" + TStfName.Text.Trim() + "%'"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (StartTime.Text.Trim() != "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
where += " and a.StfRegistertime >= '" + StartTime.Text + "'"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (EndTime.Text.Trim() != "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
where += " and a.StfRegistertime <= '" + EndTime.Text + "'"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (where != string.Empty)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
where = "Where " + where.Substring(4);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string connStr = ConfigurationManager.AppSettings.Get("DataConnectionString");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string SqlStr = "Select a.StfId as StfId,a.StfName as StfName,a.StfRealName as StfRealName,a.StfCmpName as StfCmpName,b.StfCmpMoney as StfCmpMoney,b.StfQbmoney as StfQbmoney,a.StfRegistertime as StfRegistertime From TStafferInfo a,TCmpMoney b " + where + Sqlsort;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Response.Write(SqlStr);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Response.End();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlConnection conn = new SqlConnection(connStr);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (conn.State.ToString() == "Closed") conn.Open();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
da.Fill(ds, "TStafferInfo");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (conn.State.ToString() == "Open") conn.Close();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridView1.DataSource = ds.Tables[0].DefaultView;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblCurrentIndex.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblPageCount.Text = "共 " + GridView1.PageCount.ToString() + " 页"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblRecordCount.Text = "总共 " + ds.Tables[0].Rows.Count.ToString() + " 条"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ds.Tables[0].Rows.Count == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnFirst.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnPrev.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnNext.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnLast.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblCurrentIndex.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblPageCount.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LblRecordCount.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if (GridView1.PageCount == 1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnFirst.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnPrev.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnNext.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnLast.Visible = false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 计算生成分页页码,分别为:"首 页" "上一页" "下一页" "尾 页"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnFirst.CommandName = "1"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnPrev.CommandName = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnNext.CommandName = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2).ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
btnLast.CommandName = GridView1.PageCount.ToString();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.ddlCurrentPage.Items.Clear();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 1 i <= this.GridView1.PageCount; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.ddlCurrentPage.Items.Add(i.ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
catch (Exception ex)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write("数据库错误,错误原因:" + ex.Message);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.End();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void PagerButtonClick(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
e.Row.Attributes["onmouseover"] = "ItemOver(this)"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button1_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write(Request.Form.Get("RadioName"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string sql = ""
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ViewState["DataConnectionString"] == null || ViewState["DataConnectionString"].ToString().CompareTo("") == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ViewState["DataConnectionString"] = " desc"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ViewState["DataConnectionString"] = ""
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sql = " order by " + e.SortExpression + ViewState["DataConnectionString"];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind(sql);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//DataFormatString="{0:yyyy年MM月dd日 hh时mm分ss秒}"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private bool CheckAddClientInfoForm()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int Tag = 0
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (Tag == 1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return true
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public string GetClientVisitInfoShowAnchorStr(object StfId, object StfName)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string AnchorStr = "
修改
" ![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return AnchorStr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public string GetClientVisitInfoShowCmpMoney(object StfId, object StfName)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string AnchorStr = "
充值
" ![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return AnchorStr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button3_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string str = ""
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string[] ckb = null
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
str = Request.Form.Get("checkboxname");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
ckb = str.Split(new char[] ...{ ',' });
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0 i < ckb.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{ //帐户和信息同时删除
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string StrSql = " Delete TStafferInfo where StfId ='" + ckb[i] + "'"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
String StrSql_d = " Delete TCmpMoneyInfo where StfId ='" + ckb[i] + "'"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("DataConnectionString"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlCommand Cmd = new System.Data.SqlClient.SqlCommand(StrSql, Conn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlCommand Cmd_d = new System.Data.SqlClient.SqlCommand(StrSql_d, Conn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Conn.Open();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlTransaction Trans = Conn.BeginTransaction();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Cmd.Transaction = Trans;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Cmd_d.Transaction = Trans;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Cmd.ExecuteNonQuery();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Cmd_d.ExecuteNonQuery();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Trans.Commit();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
catch (Exception Err)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Trans.Rollback();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write(Err.Message);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write("?);>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void SelectClient_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridViewBind("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1511765
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1520093
本文转自
http://blog.csdn.net/heker2007/archive/2007/03/04/1520093.aspx