ObjectDataSource 数据绑定:在 Select 方法调用之后获取对象属性

发布于 2024-08-22 16:00:47 字数 1020 浏览 8 评论 0原文

我正在使用 ObjectDataSource 控件来调用 MapInfo 对象。该对象有两个属性:

  • public IList 访问
  • public int TotalAvailable

select 方法返回一个 IList,但也会填充 TotalAvailable 属性。我已将 ObjectDataSource 中的 TypeName 设置为 MapInfo 对象,但因为 Select 方法仅返回 IList,所以我无权访问 TotalAvailable。

[DataObject(true)]
public sealed class MapInfo
{
    private IList<Visit> visits;
    private int totalCount;

    public IList<Visit> Visits
    {
        get
        {
            if (visits == null)
                visits = new List<Visit>();
            return visits;
        }
        set
        {
            visits = value;
        }
    }

    [DataObjectMethod(DataObjectMethodType.Select)]
    public IList<Visit> GetAccountVisits(DateTime startdate, DateTime enddate, string orgids, int reportlevel,
         string username, int authlevel, bool visited, bool notvisited, string accounttypeid)
    {

什么方法可以访问这个值。我知道它正在填充到 MapInfo 对象中,但从 Select 方法返回的所有内容都是 IList

I am using an ObjectDataSource control to call a MapInfo object. This object has two properties:

  • public IList Visits
  • public int TotalAvailable

The select method returns an IList but the TotalAvailable property is also populated. I have set the TypeName in the ObjectDataSource to the MapInfo object but because the Select method only returns the IList I don't have access to the TotalAvailable.

[DataObject(true)]
public sealed class MapInfo
{
    private IList<Visit> visits;
    private int totalCount;

    public IList<Visit> Visits
    {
        get
        {
            if (visits == null)
                visits = new List<Visit>();
            return visits;
        }
        set
        {
            visits = value;
        }
    }

    [DataObjectMethod(DataObjectMethodType.Select)]
    public IList<Visit> GetAccountVisits(DateTime startdate, DateTime enddate, string orgids, int reportlevel,
         string username, int authlevel, bool visited, bool notvisited, string accounttypeid)
    {

}

Is there any way to access this value. I know it is being populated in the MapInfo object but all that gets returned from the Select method is the IList

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨后咖啡店 2024-08-29 16:00:47

该数据源在选择发生后触发 Selected 事件;您可以尝试查看它是否公开了根对象。

HTH。

that datasource fires a Selected event after the select happens; you could try to see if it exposes the root object there.

HTH.

錯遇了你 2024-08-29 16:00:47

我已将 SelectMethod 的返回类型更改为:

[DataObjectMethod(DataObjectMethodType.Select)]
public MapInfo GetAccountVisits(DateTime startdate, DateTime enddate, string orgids, int reportlevel,
     string username, int authlevel, bool visited, bool notvisited, string accounttypeid)
{

在 CreateChildControls 方法中的 CompositeDataBoundControl 中,然后我使用:

DataBinder.Eval(((object[])(dataSource))[0], "Visits");

不过,我会欣赏更优雅的解决方案。

I have changed the return type of the SelectMethod to:

[DataObjectMethod(DataObjectMethodType.Select)]
public MapInfo GetAccountVisits(DateTime startdate, DateTime enddate, string orgids, int reportlevel,
     string username, int authlevel, bool visited, bool notvisited, string accounttypeid)
{

In my CompositeDataBoundControl in the CreateChildControls method, I then use:

DataBinder.Eval(((object[])(dataSource))[0], "Visits");

Would appreciate a more elegant solution though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文