网格视图分页问题 [英] grid view paging problem

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

问题描述

我有问题...我在gridview中编写以下代码进行分页.....





select gridview和goto属性窗口并单击事件按钮



双击pageindexchanging事件



并设置



i have a problem ...i write the following code for paging in gridview.....

"
select gridview and goto properties window and click on events button

double click on pageindexchanging event

and set

Allowpaging=true

// for gridview

在pageindex更改事件中我写下面的代码...





// for gridview
in pageindex changing event i write the following code...


gridview1.pageindex=e.newpageindex;
//gridbindingcode
gridview1.databind();









和我的网格查看我也使用行命令...



当我运行我的页面...它正确加载但在更改pageindex时它会在行命令上给出错误.. ..



您的行索引不能小于零..问题是什么?


"


and in my grid view i also use the row command ...

when i run my page ...its load properly but on changing pageindex it give an error on row command ....

that your row index cannot be less than zero..whats the problem frnds?

推荐答案

在gridview的rowcommand事件中尝试以下代码



Try below code in your rowcommand event of gridview

protected void gridview1_RowCommand(object sender, GridViewCommandEventArgs e)

{

        int index = 0;

        index = Convert.ToInt32(e.CommandArgument.ToString());

        GridViewRow row = gridview1.Rows[index];



}


只需调用fillgrid函数,如下所示。

解决方案1 ​​

Just call the fillgrid function as follows .
Solution 1
FillGrid();
   grdView.PageIndex = e.NewPageIndex;
   grdView.DataBind();





解决方案2

在Page index中添加以下代码更改





Solution 2
Add the following code in Page index Changing

if (CustomersGridView.EditIndex != -1)
    {
      // Use the Cancel property to cancel the paging operation.
      e.Cancel = true;

      // Display an error message.
      int newPageNumber = e.NewPageIndex + 1;
      Message.Text = "Please update the record before moving to page " +
        newPageNumber.ToString() + ".";
    }


这篇关于网格视图分页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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