Gridview & Paging Question

L

Lee

Hello all,

Fairly new to .net. Using VB.net/2005

I am having a bit of trouble implementing a data driven gridview with
paging. I am binding the grid to a DataTable at runtime (which is
created on the fly) as opposed to setting up a datasource on the page,
etc. I create the datatable and then assign it to the gridview's
datasource property and call DataBind.

At first, I kept getting an error saying that there was no handler for
the PageIndexChanging event. Not sure why there HAS to be an event
handler for that. So, I created the handler and simply assigned:

e.Cancel = False

to it and no longer received the error. However, clicking on the next
page link in the gridview does nothing except post back the page. It
doesn't switch to next page.

Is it that I must use a "sited" datasource and dataset on the page to
get this to work?

Thanks for help.

--
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
 
A

Andrew Robinson

Try removing the "e.Cancel = False" code. The GridView requites the event
handler, but you don't have to execute any code within said event handler.
 
L

Lee

Andrew Robinson enlightened me by writing:
Try removing the "e.Cancel = False" code. The GridView requites the
event handler, but you don't have to execute any code within said
event handler.

Thanks for responding. I have tried that, but same results.

--
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
 
Joined
Jul 21, 2006
Messages
1
Reaction score
0
I'm looking for the answer myself

Was there ever an answer to this issue? I have a Gridview with 2-way databinding from an ObjectDataSource that I've created a pageindexchanging event handler for, but the event runs and it just reposts the same page, despite me putting in the code
gv.PageIndex = e.newPageIndex

I tried adding to the method
gv.DataBind()

But this throws a runtime error because I don't have a DataSource for my gridview, I have a DataSourceId.

Any help would be great.
 

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

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top