I need some advice on how to acheive the desired result of my custom
page link generation. The datagrid 'built-in' page navigation only
allows either the 'Prev/Next' or the page numbers. (Prev/Next on top
and pg numbers on bottom is not an option) Therefore I am attempting
to create my own custom navigation where I am very close except for
the rendering of the page number links after clicking on one of them.
In other words, Initial page loads and everything is as expected.
Click on page 5 link and the page will reload with page 5 data,
however, the page link rendering is incorrect. The page number 5
should now be just text, instead it shows page number 1 still as text.
It does however postback the correct page number. The order of events
is click page number link, which fires setGridPage, which calls
binddata. If I make a call to buildpglink after this, I get 2 sets of
'Page Number links', one of which is correct, but I can't figure out
how to prevent it. I'm sure it's related to the fact I'm dynamically
generating these, the postback of the controls and the order or where
I make the calls. I believe that I need my pagelink to postback and
fire the event and then have all the pagelinks destroyed so that they
can be regenereated. Can someone tell me where the simple step is
that I've missed?
My codebehind basically has the following:
pageload()
if ispostback = False then
binddata()
buildPgLinks()
end if
Private Sub SetGridPage( ByVal src As Object, ByVal e as
CommandEventArgs )
dg.CurrentPageIndex = cint(e.CommandArgument)
BindData()
'BuildPageLinks()
End Sub
buildPgLinks()
'based on properties of the datagrid dg.currentpageindex and
dg.pagesize
I generate dynamically linkbuttons for the set of 'Page' Numbers I
need to
display.
if i <> artgrid.CurrentPageIndex then
genLink.CommandName = "pgLink"
genLink.CommandArgument = i.toString()
genLink.text = i.toString()
genspace = new literal
genspace.text = " "
' pl is a placeholder on the webform to contain the page number
links
pl.Controls.Add(genspace)
pl.Controls.Add(genLink)
AddHandler genLink.Command, Addressof SetGridPage
else
curpage.text = " <strong>[" & cstr(i) & "]</strong> "
pl.Controls.Add(curpage)
end if
binddata()
'retrieves data from database and binds to the datagrid
Thanks in advance,
Mark