对象数据源

发布于 2024-11-06 03:23:04 字数 955 浏览 0 评论 0原文

我正在使用对象数据源创建一个网格视图,它在提取所有记录时工作正常。但是当我想使用 selectCountMethod 时,网格不显示任何值。

我单步执行代码,我的 getInvoices (获取请求的数据)返回数据和 getInvoicesCount (获取总记录数)。但是当我浏览 gridview 的 rowdatabound 时,里面什么也没有,也没有数据显示。

这是我设置对象数据源的代码。它不起作用的任何原因或者需要做一些特殊的事情才能使 selectcount 工作?

Me.ODS.TypeName = "invoice"
Me.ODS.EnablePaging = True
Me.ODS.SelectMethod = "getInvoices"
Me.ODS.SelectCountMethod = "GetInvoiceCount"
Me.ODS.StartRowIndexParameterName = "startRowIndex"
Me.ODS.MaximumRowsParameterName = "maximumRows"
Me.ODS.SelectParameters.Add("strbu", strBusUnit)
Me.ODS.SelectParameters.Add("stremailAddress", emailAddress)
Me.ODS.SelectParameters.Add("startDate", search_startdate)
Me.ODS.SelectParameters.Add("enddate", search_enddate)
Me.ODS.SelectParameters.Add("sortExpression", sortExpression & " " & sortDirection)

With gvInvoices
   .PageIndex = intPageIndex
   .PageSize = 25
   .DataBind()
End With

I'm creating a gridview using an objectdatasource and it works fine when pulling all records. But when I want to use the selectCountMethod the grid shows no values.

I Step through the code and my getInvoices (gets the requested data) returns data and the getInvoicesCount (gets the total record count). But then when I go through the rowdatabound of the gridview there's nothing in there and no data displays.

Here is my code to set the objectdatasource. Any reasons why it wouldn't work or something special that needs to be done for getting the selectcount to work?

Me.ODS.TypeName = "invoice"
Me.ODS.EnablePaging = True
Me.ODS.SelectMethod = "getInvoices"
Me.ODS.SelectCountMethod = "GetInvoiceCount"
Me.ODS.StartRowIndexParameterName = "startRowIndex"
Me.ODS.MaximumRowsParameterName = "maximumRows"
Me.ODS.SelectParameters.Add("strbu", strBusUnit)
Me.ODS.SelectParameters.Add("stremailAddress", emailAddress)
Me.ODS.SelectParameters.Add("startDate", search_startdate)
Me.ODS.SelectParameters.Add("enddate", search_enddate)
Me.ODS.SelectParameters.Add("sortExpression", sortExpression & " " & sortDirection)

With gvInvoices
   .PageIndex = intPageIndex
   .PageSize = 25
   .DataBind()
End With

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

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

发布评论

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

评论(2

旧人 2024-11-13 03:23:04

检查返回的计数是否为整数。调试它。也许它是空的。
如果不为空,则将其解析为整数

Check if the count being returned is an integer . debug it . maybe it is null.
and if not null parse it to an integer

归途 2024-11-13 03:23:04

我能够弄清楚这一点。计数作为长整型而不是整数返回。我将其更改为整数,一切正常

I was able to figure this one out. The count was being returned as a long instead of integer. I changed it to integer and all is working great

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