带自定义分页的gridview [英] gridview with custom paging

查看:68
本文介绍了带自定义分页的gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public partial class gridviewwithlinq : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\srikanth\\webprojects\\gridviewwithlinq\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True");
    SqlDataAdapter da;
    int startindex;//it will maintain the page count
    void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState["index"] = 0;
            fillgrid();
        }
    }

    private void fillgrid()
    {
        startindex = int.Parse(ViewState["index"].ToString());
        string querry = "SELECT * from(select Row_number() over (order by id) as MyRow,*  from name) as names where MyRow > " + startindex * 10 + " and MyRow < " + ((startindex * 10) + 11) + "";
         DataSet ds = new DataSet();
        da = new SqlDataAdapter(querry, con);
        da.Fill(ds, "p");
        gridview1.DataSource = ds;
        gridview1.DataBind();
        
    }
  
    protected void button2_Click(object sender, EventArgs e)
    {
       
        ViewState["index"] = int.Parse(ViewState["index"].ToString()) + 1;
        Response.Write("the current index is"+" " + ViewState["index"].ToString());
        fillgrid();
        
    }
    protected void button1_Click(object sender, EventArgs e)
    {
       
        ViewState["index"] = int.Parse(ViewState["index"].ToString()) - 1;
        Response.Write("the current index is"+" " + ViewState["index"].ToString());
        fillgrid();
        
    }
    protected void buttonfirst_Click(object sender, EventArgs e)
    {
        ViewState["index"] = startindex;
        Response.Write("the current index is" + " " + startindex);
        fillgrid();
       
    }
    protected void buttonlast_Click(object sender, EventArgs e)
    {
        
    }
}






在这里,我编写了第一个,下一个和上一个按钮逻辑,但是我无法编写最后一页按钮逻辑....有谁能帮助我实现最后一个按钮逻辑






here i wrote first and next and previous button logics but iam unable to write lastpage button logic.... can any one help me for the last button logic

推荐答案


您去了:
在asp.net GridView中进行自定义分页 [ ^ ]

我相信您可以在这里找到您的逻辑.


--Amit
Hi,
Here you go:
Custom paging in asp.net GridView[^]

I am sure here you''ll able to find your logic.


--Amit


您好,

通过以下链接:
在GridView中进行自定义分页 [使用ASP.NET GridView进行自定义分页 [ http://www.aspsnippets. com/Articles/Custom-Paging-in-ASP.Net-GridView-using-SQL-Server-Stored-Procedure.aspx [
Hello,

Go through following links:
Custom Paging in GridView[^]
Custom paging with ASP.NET GridView[^]
http://www.aspsnippets.com/Articles/Custom-Paging-in-ASP.Net-GridView-using-SQL-Server-Stored-Procedure.aspx[^]




检查一下,
底部的网格视图中的按钮和上一个目的 [ ^ ]


Check this,
Buttons in Grid View at bottom for Next and Previous Purpose[^]


这篇关于带自定义分页的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆