ObjectDataSource не вызывает метод SelectCount - PullRequest
3 голосов
/ 23 февраля 2010

Не могли бы вы помочь мне найти проблему:

Я хочу реализовать простой пакет 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 вызывает SelectMethod2 с параметрами (0,0, "") и не вызывает GetCount.

пожалуйста, помогите мне найти проблему

Спасибо

1 Ответ

1 голос
/ 23 февраля 2010

Вы пытались использовать вместо этого GridView?

...