GridView控件中分页显示小记
2008-04-25 14:35
405 查看
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 test_Default10 : System.Web.UI.Page
{
private int mycount = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
protected void Bind()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "server=.;uid=sa;database=EastHH_Product_Quote";
con.Open();
string sqlcon = "select * from S_Bug";
SqlDataAdapter da = new SqlDataAdapter(sqlcon, con);
DataSet ds = new DataSet();
da.Fill(ds, "s");
GridView1.DataSource = ds.Tables["s"].DefaultView;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
mycount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,"id"));
}
else
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "每页小记";
e.Row.Cells[3].Text = mycount.ToString();
e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
e.Row.Font.Bold = true;
}
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Bind();
}
}
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 test_Default10 : System.Web.UI.Page
{
private int mycount = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
protected void Bind()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "server=.;uid=sa;database=EastHH_Product_Quote";
con.Open();
string sqlcon = "select * from S_Bug";
SqlDataAdapter da = new SqlDataAdapter(sqlcon, con);
DataSet ds = new DataSet();
da.Fill(ds, "s");
GridView1.DataSource = ds.Tables["s"].DefaultView;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
mycount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,"id"));
}
else
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "每页小记";
e.Row.Cells[3].Text = mycount.ToString();
e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
e.Row.Font.Bold = true;
}
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Bind();
}
}
相关文章推荐
- DbEntry采用分页技术显示数据在GridView里面并用AspNetPager控件来显示分页
- GridView控件分页显示数据
- 使用GridView控件分页显示数据
- 如何实现GridView控件分页显示数据
- 用ASP.net 的GridView控件分页显示图片,并历遍给定的文件夹中的文件绑定到GridView控
- 转:用ASP.net 的GridView控件分页显示图片 已调试成功
- 我的ASPxGridView控件的数据是在后台绑定的,但是实现不了筛选和分页的功能,只能显示一页的数据?
- 【原】关于GridView文本过长显示的问题和GridView中带有标签模版的分页问题
- GridView控件自定义分页详解
- ASP.NET基础教程-Repeater控件分页显示数据
- iOS 6编程-UIScrollView滚动视图和UIPageControl分页控件实现图像分页显示(2)
- GridView控件自定义分页
- 扩展GridView控件(10) - 自定义分页样式
- ASP.NET的控件Gridview在Firefox中的Border显示问题
- GridView数据绑定控件的模版列时设置显示的格式
- GridView中使用分页控件
- ASP.Net2.0 GridView 多列排序,显示排序图标,分页
- 无记录时显示gridview表头,并增加一行显示“没有记录”【绑定SqlDataSource控件时】
- GridView自动生成列时,利用DIV控制显示长宽 控件数据行和表头文字不换行
- GridView 自带的全选表头显示文本,重绘表头和表头绑定控件