473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NEXT record Link

Hello, i'm working on a greeting card website, there is a page where i'm
showing

greeting cards, i have done paging on this page with using Datalist and its
working well but i have a problem is on Next button i want to disable Next
button link when user is on last page so pls tell me how can i do it in
ASP.NET, below i'm giving my page code,pls review it.
<%@ Import NameSpace="Syst em.Data" %>
<%@ Import NameSpace="Syst em.Data.oledb" %>
<html>
<head>
<title>Paging in Datalist - by Das</title>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
If Not Page.IsPostBack () Then
intPageSize.Tex t = "5"
intCurrIndex.Te xt = "0"
DataBind()
End If
End Sub

Private Sub DataBind()
Dim cs,d,q2 as string
Dim c,rc,i as integer
c=Request.Query String("catID")
'Response.Write (c)
q2="Select count(*) from cards where categoryID=Cint ('"& c &"') "
Dim pics as Arraylist=new Arraylist()
cs=System.confi guration.Config urationSettings .Appsettings("c onnstr")
Dim objconn as new oledbConnection (cs)

Dim objcomm as new oledbCommand(q2 ,objconn)
objconn.open()
rc=objcomm.Exec utescalar()
'Response.Write (rc)
Dim objDA As New oledbdataAdapte r("Select * from cards where
categoryID=Cint ('"& c &"')", objConn)
Dim objDS As New DataSet()
objDA.Fill(objD S)
intRecordCount. Text = CStr(objDS.Tabl es(0).Rows.Coun t)
objDS = Nothing
objDS = New DataSet()
objDA.Fill (objDS, Cint(intCurrInd ex.Text), CInt(intPageSiz e.Text), "cards")
Dim objtable as new DataTable
Dim objrow as DataRow
objtable=objDS. Tables("cards")
for i=0 to 4
objrow=objTable .rows(i)
d="<a href=form.asp?c id=" & objrow("cardID" ) & ">"& _
"<img src='Friendship/"& objrow("cardthu mbnail") &"' border=0></a>"
pics.Add(d)
Next
dList.Datasourc e=pics
dList.DataBind( )
objConn.Close()
PrintStatus()
End Sub

Public Sub ShowFirst(ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Te xt = "0"
DataBind()
End Sub
Public Sub ShowPrevious(By Val s As Object, ByVal e As EventArgs)
intCurrIndex.Te xt = Cstr(Cint(intCu rrIndex.Text) - CInt(intPageSiz e.Text))
If CInt(intCurrInd ex.Text) < 0 Then
intCurrIndex.Te xt = "0"
End If
DataBind()
End Sub

Public Sub ShowNext(ByVal s As Object, ByVal e As EventArgs)
If CInt(intCurrInd ex.Text) + 1 < CInt(intRecordC ount.Text) Then
intCurrIndex.Te xt = CStr(CInt(intCu rrIndex.Text) + CInt(intPageSiz e.Text))
End If
DataBind()
End Sub

Public Sub ShowLast(ByVal s As Object, ByVal e As EventArgs)
Dim tmpInt as Integer
tmpInt = CInt(intRecordC ount.Text) Mod CInt(intPageSiz e.Text)
If tmpInt > 0 Then
intCurrIndex.Te xt = Cstr(CInt(intRe cordCount.Text) - tmpInt)
Else
intCurrIndex.Te xt = Cstr(CInt(intRe cordCount.Text) - CInt(intPageSiz e.Text))
End If
DataBind()
End Sub

Private Sub PrintStatus()
lblStatus.Text = "Total Records:<b>" & intRecordCount. Text
lblStatus.Text += "</b> - Showing Page:<b> "
lblStatus.Text += CStr(CInt(CInt( intCurrIndex.Te xt) /
CInt(intPageSiz e.Text)+1))
lblStatus.Text += "</b> of <b>"
If (CInt(intRecord Count.Text) Mod CInt(intPageSiz e.Text)) > 0 Then
lblStatus.Text += CStr(CInt(CInt( intRecordCount. Text) /
CInt(intPageSiz e.Text)+1))
Else
lblStatus.Text += CStr(CInt(intRe cordCount.Text) / CInt(intPageSiz e.Text))
End If
lblStatus.Text += "</b>"
End Sub
</script>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h2 align="center"> <font face="verdana"> Paging in DataList</font></h2>

<asp:DataList ID="dList" Runat="server" Width="100%" RepeatColumns=" 3"
BorderWidth="1" EnableViewState ="False">
<ItemTemplate >
<%# Container.DataI tem%>
</ItemTemplate>
</asp:DataList>
<table width=100% align="right">
<tr>
<td width=76% align=left> <asp:label ID="lblStatus"
Runat="server"
Font-Name="verdana"
Font-Size="10pt" /> </td>
<td width=6%> <font size="2"><a href="datalistp aging.aspx#this "
ID="hrefFirst"
onserverclick=" ShowFirst"
runat="server"> First</a> </font></td>
<td width=6%> <font size="2"><a href="datalistp aging.aspx#this "
ID="hrefPreviou s"
onserverclick=" ShowPrevious"
runat="server"> Prev</a> </font></td>
<td width=6%>
<a href="datalistp aging.aspx#this " ID="hrefNext" onserverclick=" ShowNext"
runat="server">
<font size="2">NEXT</font></a> </td>
<td width=6%> <font size="2">
<a href="datalistp aging.aspx#this "
ID="hrefLast"
onserverclick=" ShowLast"
runat="server"> Last</a> </font></td>
</tr>
</table>
<asp:label ID="intCurrInde x"
Visible="False"
Runat="server" />
<asp:label ID="intPageSize "
Visible="False"
Runat="server" />

<asp:label ID="intRecordCo unt"
Visible="False"
Runat="server" />
</form>
</body>
</html>



Nov 19 '05 #1
1 1349
You may want to try sonething like this, the code below may not be 100%
right but it should give you the idea.
<asp:linkbutt on ....
Enabled = '<% =NextStatus() %>'

Done in VB
Server side

public function NextStatus()
return CInt(intCurrInd ex.Text)< CInt(intRecordC ount.Text)
end sub
"=?Utf-8?B?YXNhZA==?=" <as**@discussio ns.microsoft.co m> wrote in
news:58******** *************** ***********@mic rosoft.com:
Hello, i'm working on a greeting card website, there is a page where
i'm showing

greeting cards, i have done paging on this page with using Datalist
and its working well but i have a problem is on Next button i want to
disable Next button link when user is on last page so pls tell me how
can i do it in ASP.NET, below i'm giving my page code,pls review it.
<%@ Import NameSpace="Syst em.Data" %>
<%@ Import NameSpace="Syst em.Data.oledb" %>
<html>
<head>
<title>Paging in Datalist - by Das</title>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
If Not Page.IsPostBack () Then
intPageSize.Tex t = "5"
intCurrIndex.Te xt = "0"
DataBind()
End If
End Sub

Private Sub DataBind()
Dim cs,d,q2 as string
Dim c,rc,i as integer
c=Request.Query String("catID")
'Response.Write (c)
q2="Select count(*) from cards where categoryID=Cint ('"& c &"') "
Dim pics as Arraylist=new Arraylist()
cs=System.confi guration.Config urationSettings .Appsettings("c onnstr")
Dim objconn as new oledbConnection (cs)

Dim objcomm as new oledbCommand(q2 ,objconn)
objconn.open()
rc=objcomm.Exec utescalar()
'Response.Write (rc)
Dim objDA As New oledbdataAdapte r("Select * from cards where
categoryID=Cint ('"& c &"')", objConn)
Dim objDS As New DataSet()
objDA.Fill(objD S)
intRecordCount. Text = CStr(objDS.Tabl es(0).Rows.Coun t)
objDS = Nothing
objDS = New DataSet()
objDA.Fill (objDS, Cint(intCurrInd ex.Text), CInt(intPageSiz e.Text),
"cards") Dim objtable as new DataTable
Dim objrow as DataRow
objtable=objDS. Tables("cards")
for i=0 to 4
objrow=objTable .rows(i)
d="<a href=form.asp?c id=" & objrow("cardID" ) & ">"& _
"<img src='Friendship/"& objrow("cardthu mbnail") &"' border=0></a>"
pics.Add(d)
Next
dList.Datasourc e=pics
dList.DataBind( )
objConn.Close()
PrintStatus()
End Sub

Public Sub ShowFirst(ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Te xt = "0"
DataBind()
End Sub
Public Sub ShowPrevious(By Val s As Object, ByVal e As EventArgs)
intCurrIndex.Te xt = Cstr(Cint(intCu rrIndex.Text) -
CInt(intPageSiz e.Text)) If CInt(intCurrInd ex.Text) < 0 Then
intCurrIndex.Te xt = "0"
End If
DataBind()
End Sub

Public Sub ShowNext(ByVal s As Object, ByVal e As EventArgs)
If CInt(intCurrInd ex.Text) + 1 < CInt(intRecordC ount.Text) Then
intCurrIndex.Te xt = CStr(CInt(intCu rrIndex.Text) +
CInt(intPageSiz e.Text)) End If
DataBind()
End Sub

Public Sub ShowLast(ByVal s As Object, ByVal e As EventArgs)
Dim tmpInt as Integer
tmpInt = CInt(intRecordC ount.Text) Mod CInt(intPageSiz e.Text)
If tmpInt > 0 Then
intCurrIndex.Te xt = Cstr(CInt(intRe cordCount.Text) - tmpInt)
Else
intCurrIndex.Te xt = Cstr(CInt(intRe cordCount.Text) -
CInt(intPageSiz e.Text)) End If
DataBind()
End Sub

Private Sub PrintStatus()
lblStatus.Text = "Total Records:<b>" & intRecordCount. Text
lblStatus.Text += "</b> - Showing Page:<b> "
lblStatus.Text += CStr(CInt(CInt( intCurrIndex.Te xt) /
CInt(intPageSiz e.Text)+1))
lblStatus.Text += "</b> of <b>"
If (CInt(intRecord Count.Text) Mod CInt(intPageSiz e.Text)) > 0 Then
lblStatus.Text += CStr(CInt(CInt( intRecordCount. Text) /
CInt(intPageSiz e.Text)+1))
Else
lblStatus.Text += CStr(CInt(intRe cordCount.Text) /
CInt(intPageSiz e.Text)) End If
lblStatus.Text += "</b>"
End Sub
</script>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h2 align="center"> <font face="verdana"> Paging in DataList</font></h2>

<asp:DataList ID="dList" Runat="server" Width="100%" RepeatColumns=" 3"
BorderWidth="1" EnableViewState ="False">
<ItemTemplate >
<%# Container.DataI tem%>
</ItemTemplate>
</asp:DataList>
<table width=100% align="right">
<tr>
<td width=76% align=left> <asp:label ID="lblStatus"
Runat="server"
Font-Name="verdana"
Font-Size="10pt" /> </td>
<td width=6%> <font size="2"><a href="datalistp aging.aspx#this "
ID="hrefFirst"
onserverclick=" ShowFirst"
runat="server"> First</a> </font></td>
<td width=6%> <font size="2"><a href="datalistp aging.aspx#this "
ID="hrefPreviou s"
onserverclick=" ShowPrevious"
runat="server"> Prev</a> </font></td>
<td width=6%>
<a href="datalistp aging.aspx#this " ID="hrefNext"
onserverclick=" ShowNext" runat="server">
<font size="2">NEXT</font></a> </td>
<td width=6%> <font size="2">
<a href="datalistp aging.aspx#this "
ID="hrefLast"
onserverclick=" ShowLast"
runat="server"> Last</a> </font></td>
</tr>
</table>
<asp:label ID="intCurrInde x"
Visible="False"
Runat="server" />
<asp:label ID="intPageSize "
Visible="False"
Runat="server" />

<asp:label ID="intRecordCo unt"
Visible="False"
Runat="server" />
</form>
</body>
</html>





Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
10964
by: george | last post by:
Can anyone help? I query a database and return a result on the column "reference". There might be 7 listings. Each row is displayed in a table, with links through to a detail page. I am working on having a "previous" record and a "next" record link on the detail page. This code below works, for the "next" record, by searching the values in the array $myarray for the variable $ref. It then returns the key value and the key value, as a...
9
1925
by: Leroy | last post by:
I really need some help with showing pages of results from queries in say like groups of 20 with next and previous buttons or links. I'm having a lot of trouble figuring out the logic of such a script. I know someone has written this script before. Please help.
3
4747
by: William Wisnieski | last post by:
Hello Everyone, Access 2000, I have a main unbound form with a bound datasheet subform . The subform is bound to a query that returns records based on criteria in the main form. The user then double clicks a row on the datasheet subform to open yet another form bound to a table . These two forms are linked by the field. So far so good.
2
1784
by: asad | last post by:
hello friends, how ru all I want to create a custom paging logic in ASP.NET with a next link for example if i have 100 pages record so i want to show 6 pages link on page one and next link like that 1 2 3 4 5 6 <Next>
11
3529
by: scsTiger | last post by:
I am using Access 2000 as the front end and MS SQL 2000 as the backend. I have a one record form that I set using something like: strSQL = "SELECT * FROM dbo_WBACCT WHERE (((dbo_WBACCT.ACCOUNT)='"423456"'));" Me.RecordSource = strSQL Obviously I only want one record at a time because the database is very big.
2
4331
by: gavm360 | last post by:
Hello, I have a data entry form that has a button to copy the values of fields (CASECODE,STEPDES,CBOANSWER) into the fields (CASECODE,STEPDES,ANSWER) of a subform on the page. Private Sub cmdANSWER_Click() Forms!FRMMENU1!FRMANSWERSsubform! = Forms!FRMMENU1! Forms!FRMMENU1!FRMANSWERSsubform! = Me!
10
2720
by: fran7 | last post by:
Hi, Anyone know the simplest solution to add a next record link. I have this <a href="page.asp?author=<%=rsCard("author")%>">link</a> I am on a page with one record and want a link to go to the next record on the same page and display that. thanks in advance.
2
1942
by: fran7 | last post by:
Hi, I wonder if anyone could point me in the right direction. I have this script that gets a random record from my database. All records have an id, how do I instead of random just go to the next record? Any pointers would be great. Thanks Richard <% ' ADO Constant. Dont change this ' Connection string and SQL statement
3
5690
by: mbilalk | last post by:
Hello, Well here goes, I am using Microsoft Access to design a user interface for SQL Server database, I am currntly using the project method. I have manged to link it up and get my form to show the record, but when I go to click on next record it is not showing the next record. Where you have the next buttons it shows how many records there are, in this instance there is 706, but always seems to get stuck on the first record, this is the...
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.