| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1744 人关注过本帖
标题:gridview分页(如何把分页模板设为隐藏)
只看楼主 加入收藏
雪雨星风
Rank: 1
来 自:北京
等 级:新手上路
威 望:1
帖 子:566
专家分:0
注 册:2007-10-11
结帖率:100%
收藏
 问题点数:0 回复次数:5 
gridview分页(如何把分页模板设为隐藏)
//分页
    protected void pageindex()
    {
        try
        {
            SqlConnection mysqlconn = new SqlConnection(publicclass.getconnstr());
            mysqlconn.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select * from UF_POST", mysqlconn);
            DataSet ds = new DataSet();
            sda.Fill(ds, "UF_POST");
            GridView1.DataSource = ds.Tables["UF_POST"];
            GridView1.AllowPaging = true;
            GridView1.PageSize = 10;
            GridView1.DataBind();
            shou.Enabled = true;
            shang.Enabled = true;
            xia.Enabled = true;
            wei.Enabled = true;
            if (GridView1.PageIndex == 0)
            {
                shou.Enabled = false;
                shang.Enabled = false;
            }
            if (GridView1.PageIndex == GridView1.PageCount - 1)
            {
                xia.Enabled = false;
                wei.Enabled = false;
            }
            if (!IsPostBack)
            {
                for (int i = 0; i < GridView1.PageCount; i++)
                {
                    DropDownList1.Items.Add(i.ToString());
                }
            }
            Label1.Text = GridView1.PageCount.ToString();
            Label2.Text = GridView1.PageSize.ToString();
            Label3.Text = GridView1.PageIndex.ToString();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }   
    //首页
    protected void shou_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = 0;
        pageindex();
    }
    //上一页
    protected void shang_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = GridView1.PageIndex - 1;
        pageindex();
    }
    //下一页
    protected void xia_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = GridView1.PageIndex + 1;
        pageindex();
    }
    //尾页
    protected void wei_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = GridView1.PageCount - 1;
        pageindex();
    }
    //跳转
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridView1.PageIndex = Convert.ToInt32(DropDownList2.SelectedItem.Text);
        Label3.Text = DropDownList2.Text;
        pageindex();
    }
搜索更多相关主题的帖子: gridview 模板 隐藏 
2008-06-20 09:49
残影留香
Rank: 1
来 自:广西南宁
等 级:新手上路
帖 子:193
专家分:0
注 册:2008-3-19
收藏
得分:0 
GridView 有个设罢是否显示分页的属性,把它设为flase就可以了
2008-06-20 11:37
雪雨星风
Rank: 1
来 自:北京
等 级:新手上路
威 望:1
帖 子:566
专家分:0
注 册:2007-10-11
收藏
得分:0 
已经为flase了
代码中还必须把它定为true
GridView1.AllowPaging = true;

C#发烧友QQ群1:5953354   QQ群2:68096127  QQ群3:30217249  QQ群4:37023079   为了更好方便大家交流学习,请不要重复加群
2008-06-20 11:55
雪雨星风
Rank: 1
来 自:北京
等 级:新手上路
威 望:1
帖 子:566
专家分:0
注 册:2007-10-11
收藏
得分:0 
在控件属性中没设分页  
但是在代码不加GridView1.AllowPaging = true;
是不能进行代码分页的

C#发烧友QQ群1:5953354   QQ群2:68096127  QQ群3:30217249  QQ群4:37023079   为了更好方便大家交流学习,请不要重复加群
2008-06-20 14:25
小乌龟
Rank: 2
等 级:新手上路
威 望:4
帖 子:1291
专家分:0
注 册:2007-9-28
收藏
得分:0 
[bo][un]雪雨星风[/un] 在 2008-6-20 14:25 的发言:[/bo]

在控件属性中没设分页  
但是在代码不加GridView1.AllowPaging = true;
是不能进行代码分页的

I don't agree with you,you don't need set attribute(AllowPageing) is ture in .cs page again.

[[it] 本帖最后由 小乌龟 于 2008-6-20 19:50 编辑 [/it]]
2008-06-20 19:47
残影留香
Rank: 1
来 自:广西南宁
等 级:新手上路
帖 子:193
专家分:0
注 册:2008-3-19
收藏
得分:0 
还用英语回答问题!!!!!!!!!!!!!!!!
2008-06-21 15:42
快速回复:gridview分页(如何把分页模板设为隐藏)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029831 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved