Click here to Skip to main content
15,906,624 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how to run a flash movie Pin
kirthikirthi2-Aug-06 0:44
kirthikirthi2-Aug-06 0:44 
GeneralRe: how to run a flash movie Pin
Amit Agarrwal2-Aug-06 1:51
Amit Agarrwal2-Aug-06 1:51 
GeneralRe: how to run a flash movie Pin
kirthikirthi2-Aug-06 2:00
kirthikirthi2-Aug-06 2:00 
GeneralRe: how to run a flash movie Pin
Amit Agarrwal2-Aug-06 2:42
Amit Agarrwal2-Aug-06 2:42 
AnswerRe: how to run a flash movie Pin
Ista2-Aug-06 4:00
Ista2-Aug-06 4:00 
QuestionProblem in vb.net (asp.net) [modified] Pin
amaneet1-Aug-06 18:43
amaneet1-Aug-06 18:43 
AnswerRe: Problem in vb.net (asp.net) Pin
Ista2-Aug-06 4:02
Ista2-Aug-06 4:02 
QuestionPaging in ASP.NET(separate code in .vb file) Pin
farzad moayedi1-Aug-06 18:07
farzad moayedi1-Aug-06 18:07 
Hi , I Hope You fine.
I have some problem with this code for paging in asp.net
this bottom code work correctly without any error but when
I try to place separate code in .VB file then error is begin and occured .I want to separate this code and compiling .vb code using VBC.exe later .(bin/paging.dll)
when do it like me so you retrive only < Previous Page Next Page > in your web browser and you don't retrive list Of data in your web browser.
then i try this job and place <% dopagin() %> in paging.aspx file between ...
then i retrive list of data but when you click next you cannot navigate than more 1 page and when
you click previous page you get error "Index -5 is not non-negative and below total rows count"
how can i correct this code .somebody help me please
thank you very much


-------------Correct pagingDS.aspx Code begin ---------------------

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>


Dim pagedData As New pagedDataSource

Sub Page_Load(byVal obj As Object, byVal e As EventArgs)
doPaging()
End Sub

Function getTheData() As DataTable
Dim DS As New DataSet()
Dim strConnect As New SQLConnection("server=localhost;uid=sa;pwd=relayer;Database=Northwind")
Dim objSQLAdapter As New SQLDataAdapter("SELECT companyName, contactName, contactTitle FROM customers", strConnect)
objSQLAdapter.Fill(DS, "customers")

Return DS.Tables("customers").Copy
End Function

Sub doPaging()
pagedData.DataSource = getTheData().DefaultView
pagedData.AllowPaging = True
pagedData.PageSize = 5

Try
pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString()
Catch ex As Exception
pagedData.CurrentPageIndex = 0
End Try

btnPrev.Visible = ( NOT pagedData.IsFirstPage )
btnNext.Visible = ( NOT pagedData.IsLastPage )

pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " & pagedData.PageCount

theDataList.DataSource = pagedData
theDataList.DataBind()
End Sub

Public Sub Prev_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex - 1))
End Sub

Public Sub Next_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex + 1))
End Sub



<title>Paging with ASP.NET - DataSet Example - VB.NET



<asp:label id="pageNumber" runat="server">
<asp:datalist id="theDataList" runat="server">
<itemtemplate>

Company Name: <%# DataBinder.Eval(Container.DataItem, "companyName") %>
Contact Name: <%# DataBinder.Eval(Container.DataItem, "contactName") %>
Contact Title: <%# DataBinder.Eval(Container.DataItem, "contactTitle") %>


<separatortemplate>





<asp:linkbutton id="btnPrev" text="<" onclick="Prev_Click" runat="server">
<asp:linkbutton id="btnNext" text=">" onclick="Next_Click" runat="server">




-------------------Paging.aspx End Code-----------------------------------------


***********************************************************************


---------------MY .ASPX file begin------------------------

<%@ Page src="paging.vb" language="vb" AutoEventWireup="false" Explicit="True" Inherits="farhad.myfunction2" ContentType="text/html" %>



<title>Paging with ASP.NET - DataSet Example - VB.NET



<asp:label id="pageNumber" runat="server">
<asp:datalist id="theDataList" runat="server">
<itemtemplate>


Company Name: <%# DataBinder.Eval(Container.DataItem, "companyName") %>
Contact Name: <%# DataBinder.Eval(Container.DataItem, "contactName") %>
Contact Title: <%# DataBinder.Eval(Container.DataItem, "contactTitle") %>



<separatortemplate>





<asp:linkbutton id="btnPrev" text="< Previous Page" onclick="Prev_Click" runat="server">
<asp:linkbutton id="btnNext" text="Next Page > " onclick="Next_Click" runat="server">




------------End My ASPX file ------------------------------

*************************************************
-------MY .VB Code AND CLASS begin--> Paging.vb --------------------
Imports System
Imports System.Data
Imports System.Data.SQLClient
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Webcontrols
Imports System.Xml


namespace farhad

public class myfunction2 : Inherits Page

public pagedData As New pagedDataSource
public ds As New DataSet()
public strConnect As New SQLConnection("server=localhost;uid=sa;pwd=mysecretpass;Database=northwind")
public objSQLAdapter As New SQLDataAdapter("SELECT companyName, contactName, contactTitle FROM customers", strConnect)
public btnPrev AS LinkButton
public btnNext AS LinkButton
public pageNumber AS Label
public theDataList AS DataList

public Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
dopaging()
end sub
public function getTheData() As DataTable

objSQLAdapter.Fill(DS, "customers")

Return DS.Tables("customers").Copy
End function

public Sub doPaging()
pagedData.DataSource = getTheData().DefaultView
pagedData.AllowPaging = True
pagedData.PageSize = 5

Try
pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString()
Catch ex As Exception
pagedData.CurrentPageIndex = 0
End Try

btnPrev.Visible = ( NOT pagedData.IsFirstPage )
btnNext.Visible = ( NOT pagedData.IsLastPage )

pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " & pagedData.PageCount

theDataList.DataSource = pagedData
theDataList.DataBind()
End Sub

public Sub Prev_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex - 1))
End Sub

public Sub Next_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex + 1))
End Sub

end class
end namespace
----------------------End My CLASS IN paging.VB FILE----------
QuestionUsing DataBind.Eval in the Code Behind Pin
TheMajorRager1-Aug-06 13:37
TheMajorRager1-Aug-06 13:37 
AnswerRe: Using DataBind.Eval in the Code Behind Pin
minhpc_bk1-Aug-06 15:23
minhpc_bk1-Aug-06 15:23 
GeneralRe: Using DataBind.Eval in the Code Behind Pin
Amit Agarrwal1-Aug-06 21:33
Amit Agarrwal1-Aug-06 21:33 
AnswerRe: Using DataBind.Eval in the Code Behind Pin
Ista2-Aug-06 4:05
Ista2-Aug-06 4:05 
QuestionView State Dynamic Fields Pin
smarttom991-Aug-06 13:19
smarttom991-Aug-06 13:19 
AnswerRe: View State Dynamic Fields Pin
minhpc_bk1-Aug-06 15:24
minhpc_bk1-Aug-06 15:24 
QuestionWebservice from Javascript Pin
seee sharp1-Aug-06 7:07
seee sharp1-Aug-06 7:07 
AnswerRe: Webservice from Javascript [modified] Pin
Tim Kohler1-Aug-06 9:38
Tim Kohler1-Aug-06 9:38 
QuestionCache vs Application variable Pin
honeyman_can1-Aug-06 6:35
honeyman_can1-Aug-06 6:35 
AnswerRe: Cache vs Application variable Pin
Tim Kohler1-Aug-06 8:52
Tim Kohler1-Aug-06 8:52 
QuestionDynamic User Control Creation Pin
sonicsqwirl1-Aug-06 5:54
sonicsqwirl1-Aug-06 5:54 
AnswerRe: Dynamic User Control Creation Pin
Are Jay1-Aug-06 8:51
Are Jay1-Aug-06 8:51 
AnswerRe: Dynamic User Control Creation Pin
minhpc_bk1-Aug-06 15:29
minhpc_bk1-Aug-06 15:29 
AnswerRe: Dynamic User Control Creation Pin
user55691-Aug-06 22:26
user55691-Aug-06 22:26 
QuestionHow to keep a tooltip for Pageindex of numeric in Datagrid Pin
narendrakumarp1-Aug-06 5:53
narendrakumarp1-Aug-06 5:53 
AnswerRe: How to keep a tooltip for Pageindex of numeric in Datagrid Pin
minhpc_bk1-Aug-06 16:02
minhpc_bk1-Aug-06 16:02 
QuestionASP.NET 2.0 TreeView control Pin
Omkar Ghaisas1-Aug-06 5:39
Omkar Ghaisas1-Aug-06 5:39 

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.