4

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
DavRob60
  • 3,517
  • 7
  • 34
  • 56
Robert
  • 3,074
  • 3
  • 24
  • 32
  • 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. – Robert May 09 '11 at 15:16
  • the correct way would be to post this as an answer and accept it when possible. On that way the question wouldn't stay open. – Tim Schmelter Jun 10 '11 at 15:02
  • @Tim Schmelter thanks. answered. I wasn't sure if that was the right thing to do. – Robert Jun 14 '11 at 04:28

2 Answers2

1

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

Rami Sarieddine
  • 5,396
  • 35
  • 41
1

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

Robert
  • 3,074
  • 3
  • 24
  • 32
  • However, your answer is so similar to @Ramie's that i wouldn't have created an anawer by myself but accepted Ramie's with a comment what actually was wrong so that he could add that to his answer possibly. – Tim Schmelter Jun 14 '11 at 06:54
  • I've seen only now that he has posted his answer after you have posted what was wrong. That isn't good style, so forget the last comment. – Tim Schmelter Jun 14 '11 at 07:01