GridView“GridView1”触发了未处理的 PageIndexChanging 事件
我创建了:
- 一个母版页和一个名为“详细信息”的内容页。
- 在按钮单击事件上,在网格视图中显示数据。
- 在网格视图中,列是自动生成的。
- 我想在网格视图中显示 11 列,但它比页面多 尺寸。
为此该怎么办?
我已经为数据库连接代码创建了 sql 帮助程序文件并调用该方法,而不是使用 sqldatasource 进行连接。
当我尝试进行分页时,出现错误:
GridView“GridView1”触发了 PageIndexChanging 事件,但事实并非如此 已处理。
I have created:
- one master page and one content page called Detail.
- On Button click event, displaying data in grid view.
- In grid view, columns are autogenerated.
- I wanted to show 11 column in grid view, but it is more than page
size.
What to do for this?
I have created sql helper file for database connection code and calling that method, not using sqldatasource for connection.
When I trying to do paging, getting error:
The GridView 'GridView1' fired event PageIndexChanging which wasn't
handled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您需要在后面的代码中声明一个处理 PageIndexChanging 事件的方法。
与此类似的内容:
提供示例代码:
这是标记:
生成以下内容:
You need to declare a method on your code behind that handles the PageIndexChanging event.
Something similar to this:
Providing sample code:
And this is the markup:
Produces this:
对于分页,您可以使用 OnPageIndexChanging...
例如,
您必须在 GridView 中使用 OnPageIndexChanging="gvdetails_PageIndexChanging"...
您必须将以下代码写入代码后面的事件中,如了解
更多详细信息您可以在此处查看以下链接我在我的文章中使用页面索引更改...
这里我使用PageIndexChange
我希望这会对您有所帮助....与其他人分享...谢谢!
For Paging you can use OnPageIndexChanging for this....
For Example
you have to use OnPageIndexChanging="gvdetails_PageIndexChanging" in your GridView...
You have to write below code into event in code behind like
For more detail you can check the below link here I am using page Index change in my article...
Here I use PageIndexChange
I hope this will helps you....Share it with others...Thanks!
这是最终的答案:
This is the final answer:
您只需将其添加到您的代码中:
you simply add this to your code :
为了解决这个问题,我必须仔细查看我的数据源和数据键。我有一组从 SQL Server 返回的记录,我所做的是将它们绑定到 POCO。该类有几个 Integer 类型的公共属性。这些整数是我在网格上的数据键。我用字符串替换了它们的类型,以绕过转换问题。
To fix this, I had to take a closer look at my datasource and datakeys. I have a set of records that are returned from SQL Server and what I was doing is binding them to a POCO. This class had several public properties of type Integer. These Integers were my datakeys on the grid. I replaced their type with a string instead to bypass the casting issue.