Click here to Skip to main content
16,004,974 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: a problem with .net framework Pin
kiran kumar[Intelligroup]14-Sep-06 1:08
kiran kumar[Intelligroup]14-Sep-06 1:08 
GeneralRe: a problem with .net framework Pin
Sebastian T Xavier14-Sep-06 1:17
Sebastian T Xavier14-Sep-06 1:17 
AnswerRe: a problem with .net framework Pin
GeetMunjal14-Sep-06 3:02
GeetMunjal14-Sep-06 3:02 
GeneralRe: a problem with .net framework Pin
Sebastian T Xavier18-Sep-06 0:11
Sebastian T Xavier18-Sep-06 0:11 
QuestionHow to Disable Back button and Forward Button in Internet Explorer? Pin
pubududilena13-Sep-06 23:34
pubududilena13-Sep-06 23:34 
AnswerRe: How to Disable Back button and Forward Button in Internet Explorer? Pin
kiran kumar[Intelligroup]13-Sep-06 23:47
kiran kumar[Intelligroup]13-Sep-06 23:47 
Questioncustom paging <<prev 1 2 3 4 >>Next Pin
max_dev2006@yahoo.com13-Sep-06 23:23
max_dev2006@yahoo.com13-Sep-06 23:23 
AnswerRe: custom paging <<prev 1 2 3 4 >>Next Pin
Kartik Rathi14-Sep-06 0:10
Kartik Rathi14-Sep-06 0:10 
This is complete code with stored procedure.Try this.This will definitely work.

Imports System.Data.SqlClient
Imports System.data
Imports System.Collections
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Pagebind(1)
End Sub
Public Function Pagebind(ByVal pg As Integer)
Dim nor As Integer
Dim repcol As Integer
nor = DropDownList1.SelectedValue
If (nor <= 4) Then
repcol = nor
Else
repcol = nor / 2
End If
DataList1.RepeatColumns = repcol
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("testConn").ConnectionString
con.Open()
Dim cmd As New SqlCommand
cmd.CommandText = "paging"
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@pagenumber", SqlDbType.Int).Value = pg
cmd.Parameters.Add("@pagesize", SqlDbType.Int).Value = nor
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
dr.Read()
Dim tot As Int32
tot = dr(0)
Label1.Text = pg.ToString()
Label2.Text = "of"
Label3.Text = Convert.ToInt32(tot / nor).ToString
Dim i As Int32
Dim ar As New ArrayList
For i = 1 To Convert.ToInt32(Label3.Text)
ar.Add(i.ToString())
Next i
DataList2.RepeatColumns = ar.Count
DataList2.DataSource = ar
DataList2.DataBind()
If (dr.NextResult()) Then
DataList1.DataSource = dr
DataList1.DataBind()
End If
dr.Close()
cmd.Dispose()
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
If pg = 1 Then
Button1.Enabled = False
Button2.Enabled = False
End If
If pg = Convert.ToInt32(Label3.Text) Then
Button3.Enabled = False
Button4.Enabled = False
End If

End Function

Protected Sub DataList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataList2.SelectedIndexChanged
Pagebind(DataList1.SelectedIndex + 1)
End Sub

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Pagebind(1)
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Pagebind(1)
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Pagebind(Convert.ToInt32(Label1.Text) - 1)
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Pagebind(Convert.ToInt32(Label1.Text) + 1)
End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
Pagebind(Convert.ToInt32(Label3.Text))
End Sub
End Class



CREATE PROCEDURE paging
@pagenumber int,
@pagesize int

/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
AS

declare @srec int
declare @erec int
declare @spid int
declare @epid int
declare @rc int

set @srec=@pagenumber*@pagesize-@pagesize+1

declare c_prd scroll cursor for
select productid from products order by productid

open c_prd
fetch absolute @srec from c_prd into @spid
select @rc=count(*) from products
where productid>@spid

if @rc < @pagesize
Begin
set @erec=@srec+@rc
end

else

Begin
set @erec=@pagenumber * @pagesize
end

fetch absolute @erec from c_prd into @epid

close c_prd

select count(*) from products

select productname,unitprice,categoryname from products a ,categories b
where a.categoryid=b.categoryid
and productid>=@spid
and productid<=@epid
/* SET NOCOUNT ON */
RETURN
GO

If u have any queries then don't hesitate

kartik rathi@gmail.com
kartik rathi
AnswerRe: custom paging &lt;&lt;prev 1 2 3 4 >>Next Pin
playout14-Sep-06 3:41
playout14-Sep-06 3:41 
QuestionRemote installation of Windows service Pin
Exelioindia13-Sep-06 23:11
Exelioindia13-Sep-06 23:11 
AnswerRe: Remote installation of Windows service [modified] Pin
kiran kumar[Intelligroup]13-Sep-06 23:24
kiran kumar[Intelligroup]13-Sep-06 23:24 
GeneralRe: Remote installation of Windows service Pin
max_dev2006@yahoo.com14-Sep-06 0:09
max_dev2006@yahoo.com14-Sep-06 0:09 
GeneralRe: Remote installation of Windows service Pin
kiran kumar[Intelligroup]14-Sep-06 0:21
kiran kumar[Intelligroup]14-Sep-06 0:21 
GeneralRe: Remote installation of Windows service Pin
Exelioindia14-Sep-06 0:32
Exelioindia14-Sep-06 0:32 
GeneralRe: Remote installation of Windows service Pin
kiran kumar[Intelligroup]14-Sep-06 1:01
kiran kumar[Intelligroup]14-Sep-06 1:01 
GeneralRe: Remote installation of Windows service Pin
Exelioindia14-Sep-06 1:19
Exelioindia14-Sep-06 1:19 
QuestionWebPartManager Control Pin
Kamal.Afridi13-Sep-06 21:43
Kamal.Afridi13-Sep-06 21:43 
AnswerRe: WebPartManager Control Pin
Sebastien Lachance14-Sep-06 4:53
Sebastien Lachance14-Sep-06 4:53 
GeneralRe: WebPartManager Control Pin
Kamal.Afridi18-Sep-06 20:00
Kamal.Afridi18-Sep-06 20:00 
Questionmanipulating a web application via webservices? Pin
kkadir13-Sep-06 20:38
kkadir13-Sep-06 20:38 
AnswerRe: manipulating a web application via webservices? Pin
Ramasubramaniam14-Sep-06 8:59
Ramasubramaniam14-Sep-06 8:59 
QuestionData Grid at runtime ,RETRIVING THE DATA FROM THE GRIED Pin
DotnetRafi13-Sep-06 20:32
DotnetRafi13-Sep-06 20:32 
QuestionDropdownlist ,how to retrieve valuefield Pin
Kissy1613-Sep-06 19:59
Kissy1613-Sep-06 19:59 
AnswerRe: Dropdownlist ,how to retrieve valuefield Pin
_AK_13-Sep-06 20:36
_AK_13-Sep-06 20:36 
GeneralRe: Dropdownlist ,how to retrieve valuefield Pin
Kissy1613-Sep-06 21:02
Kissy1613-Sep-06 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.