"the friendly display name"
<th********************@discussions.microsoft.co m> wrote in message
news:4C**********************************@microsof t.com...
Simple question:
How to make datagrid paging work without javascript? I have a simple
datagrid, which gets populated by a dataview, it works perfectly, paging
works too, but, as I said, it does only with javascript. I know how to set
the index of the grid etc. My Idea would be using my own links (with
query-parameters attached on them, the parameter would transport the
position of the targeted page in the grid) I just need basicaly a method with what
I can change the links the grid does create on the on the back and forwards
buttons.
The grid uses links like those as back and forward links:
<a href="javascript:__doPostBack('ctl00$DataGrid1$ctl 14$ctl01','')"
style="color:#000066;">2</a>
How can I overwrite them?
Well there may be other ways but I build a control with a hyperlink with the
necessary parameters to process the request on the server as follows (snip)
mgPager.controls.clear 'mgPager is a asp:placeholder
if intTotalPages > 1 then
dim strPage as string = "page "
dim sb as new stringbuilder(100)
....build href string here including querystring parameters (without
page number)
... you will need all the information necessary to get the next page
of data from database
dim strQuery as string = sb.tostring()
for i = 0 to intTotalPages + 2
dim ctl as new htmlanchor
select case i
case = 0
ctl.InnerHtml = HttpUtility.HtmlEncode("<<back")
ctl.title = "Go back one page."
if intPage - 1 = 0 then
ctl.href = ""
ctl.disabled = true
else
ctl.href = strQuery & "&_PageNum=" & (intPage - 1).tostring()
end if
Case = intTotalPages + 2
ctl.InnerHtml = HttpUtility.HtmlEncode(" next>>")
ctl.title = "Go forward one page."
if intPage + 1 > inttotalPages then
ctl.href = ""
ctl.disabled = true
else
ctl.href = strQuery & "&_PageNum=" & (intPage + 1).tostring()
end if
Case = intTotalPages + 1
ctl.InnerHtml = HttpUtility.HtmlEncode(" view all")
ctl.title = "View all on same page."
ctl.href = strQuery & "&_PageNum=0"
Case = intPage
ctl.InnerHtml = strPage & i.tostring()
ctl.href = ""
ctl.disabled = true
Case else
ctl.InnerHtml = strPage & i.tostring()
ctl.title = "Go to page " & i.tostring() & "."
ctl.href = strQuery & "&_PageNum=" & i.tostring()
End Select
ctl.attributes("class") = "pager"
ctl.target = "_self"
ctl.id = "p" & i.tostring()
mgPager.controls.add(ctl)
if i < intTotalPages + 2 then
mgPager.controls.add(New literalcontrol(", "))
end if
next i
end if