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.SelectPa开发者_Python百科rameters.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
Check if the count being returned is an integer . debug it . maybe it is null. and if not null parse it to an integer
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
精彩评论