ObjectDataSource不调用SelectCount方法
你能帮我找到问题吗:
实现简单的DataGrid和ObjectDataSource捆绑包
由于某种原因,我想通过分页我的.aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataGrid ID="DataGrid1" runat="server"
DataSourceID="ObjectDataSource1"
AllowPaging="true"
PageSize="2" >
</asp:DataGrid>
<asp:ObjectDataSource
runat="server"
ID="ObjectDataSource1"
TypeName="WebApplication1.AssetComments"
SelectMethod="SelectMethod2"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows"
SortParameterName="sortParameter"
SelectCountMethod="GetCount" EnablePaging="True"
/>
</form>
</body>
</html>
我的AssetComments类
namespace WebApplication1
{
public class AssetComments
{
public List<RSSFeed> SelectMethod2(int startRowIndex, int maximumRows, string sortParameter)
{
return SelectMethod2().Skip(startRowIndex).Take(maximumRows).ToList();
}
public List<RSSFeed> SelectMethod2()
{
List<RSSFeed> ret = new List<RSSFeed>(2) { new RSSFeed("11", "1111111"), new RSSFeed("22", "2222222") };
return ret;
}
public int GetCount()
{
return 55;
}
}
public class RSSFeed
{
public string Title { get; set; }
public string Description { get; set; }
public RSSFeed(string title, string description)
{
Title = title;
Description = description;
}
}
}
asp.net cals SelectMethod2带 (0,0,"") 参数并且不调用 GetCount。
请帮我找到问题
谢谢
can you please help me to find the problem:
I want to implement simple DataGrid and ObjectDataSource bundle with paging
my .aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataGrid ID="DataGrid1" runat="server"
DataSourceID="ObjectDataSource1"
AllowPaging="true"
PageSize="2" >
</asp:DataGrid>
<asp:ObjectDataSource
runat="server"
ID="ObjectDataSource1"
TypeName="WebApplication1.AssetComments"
SelectMethod="SelectMethod2"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows"
SortParameterName="sortParameter"
SelectCountMethod="GetCount" EnablePaging="True"
/>
</form>
</body>
</html>
My AssetComments class
namespace WebApplication1
{
public class AssetComments
{
public List<RSSFeed> SelectMethod2(int startRowIndex, int maximumRows, string sortParameter)
{
return SelectMethod2().Skip(startRowIndex).Take(maximumRows).ToList();
}
public List<RSSFeed> SelectMethod2()
{
List<RSSFeed> ret = new List<RSSFeed>(2) { new RSSFeed("11", "1111111"), new RSSFeed("22", "2222222") };
return ret;
}
public int GetCount()
{
return 55;
}
}
public class RSSFeed
{
public string Title { get; set; }
public string Description { get; set; }
public RSSFeed(string title, string description)
{
Title = title;
Description = description;
}
}
}
for some reason asp.net cals SelectMethod2 with (0,0,"") parameters and does not call GetCount.
please help me find the problem
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用 GridView 来代替?
Have you tried using a GridView instead?