Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Paging...All Web Examples Wrong?! 1

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey gang,

I'm just now looking at getting paging to work in my datagrids. Here's my problem though:

I have a whole bunch of examples I've found online that all basically look the same: you create a BindData sub, call it in your form load, and call it in your PageIndexChanged event. All these examples claim that the .NET framework will handle the CurrentPageIndex change and bind the datagrid accordingly, but it doesn't work! Frustrating...

My code is basically word for word what there's is, except that I'm in vs.net and they were doing it with a text editor (old school asp-like). Anybody have some tips on how to get paging to run right from within vs.net?

Thanks gang,

Jack
 
I think, in the CurrentPageIndexChange you need to add grid.CurrentPageIndex = e.NewPageIndex
before you do the databind.

Good Luck!
TealWren
 
Hey Teal,

what if I want to have the bind code in a seperate sub though? Even if I specify e as an argument, the code still flags it inside the function because its not declared.

Jack
 
You might be better off sending e.NewPageIndex to your sub as a numeric type. All that matters is somehow you need to tell your grid what page you are on.

I have a grid with dynamic column generation that has been giving me a headache for the last couple of days! One thing I noticed, it seems you have to rebind the data every time the user changes pages or selects a new item.

You could also set the grid's current page index and then call your sub.

Good luck!


TealWren
 
Hey Teal,

AHA! Now it works like a charm.

Thanks for the help
:)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top