468,306 Members | 1,166 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,306 developers. It's quick & easy.

Datagrid paging without javascript?

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?

May 25 '06 #1
1 2151

"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
May 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jeremy | last post: by
2 posts views Thread by George Durzi | last post: by
6 posts views Thread by Dee | last post: by
2 posts views Thread by Axel Dahmen | last post: by
1 post views Thread by Jon Turner | last post: by
1 post views Thread by Ed Chiu | last post: by
reply views Thread by Ray | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.