Datagrid paging without javascript?

G

Guest

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$ctl14$ctl01','')"
style="color:#000066;">2</a>

How can I overwrite them?
 
V

vMike

"the friendly display name"
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$ctl14$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
 

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,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top