NEWBIE Paging question

G

Guest

Hi All!
I have a datagrid, with paging. I get this error

AllowCustomPaging must be true and VirtualItemCount must be set for a
DataGrid with ID dgGal when AllowPaging is set to true and the selected
datasource does not implement ICollection.

Where would I set the Virtual Item Count?

Or do I have bigger problems than this?

Thanks!

Rudy

Thanks!!
 
G

Guest

Hey Vinay!

I'm using SQL, and a datagrid. If I turn "AllowCustomPaging" to true, my
data loads up, but no paging. If I set it to false, I get the error. Here
is some code.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'PreLoad Members
Dim dbConn As New SqlConnection(ConnString)
Dim drPrev As SqlDataReader
Dim cmdGal As SqlCommand

cmdGal = New SqlCommand("Gal", dbConn)
cmdGal.CommandType = CommandType.StoredProcedure
dbConn.Open()
drPrev = cmdGal.ExecuteReader
dgGal.DataSource = drPrev
dgGal.DataBind()
drPrev.Close()
dbConn.Close()
End Sub
Private Sub dgGal_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgGal.PageIndexChanged
dgGal.CurrentPageIndex = e.NewPageIndex
Dim dbConn As New SqlConnection(ConnString)
Dim drPrev As SqlDataReader
Dim cmdGal As SqlCommand

cmdGal = New SqlCommand("Gal", dbConn)
cmdGal.CommandType = CommandType.StoredProcedure
dbConn.Open()
drPrev = cmdGal.ExecuteReader
dgGal.DataSource = drPrev
dgGal.DataBind()
drPrev.Close()
dbConn.Close()
End Sub

Thanks!!
Rudy
 
D

Daniel Walzenbach

Rudy,

I am not sure if it's valid to bind a new DataSource to a Grid in the
PageIndexChanged Event. Wouldn't this resultin an endless loop? Did you
debug your code? Where exactly does your code fail?

Greetings

Daniel
 
G

Guest

Hi Dan!!
Sorry, I was goin to show where it fails, forgot.
Not sure at this point what's valid or not. I always get stuck with paging
things. Here where it fails

dbConn.Open()


Thanks!!!
 
D

Daniel Walzenbach

Hello Rudy,

and this is in which event-handler? MyBase.Load or dgGal.PageIndexChanged?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top