My original code would display the results of a search without any paging...
so i got the help on customizing the code to include paging of the results.
Before I added the paging code, when you loaded my search web page no results would show until you entered some search criteria.
when i got the paging code working the web page when initially loaded would display all the records and would page OK and when you entered some search criteria, it would filter the relevant results.
I then stumbled on how to modify this code to do what I want and it works but only for a while then it errors out on both my local and server copy. To get it working I have to run the aspx page that shows all the results, then when I run my modified page it works again ?
There must be some sort of caching going on, but im not sure??
I will include the code below from my two files, the only difference in the code is the lines I post...the 1st bit of code is the file that displays all the rows of data when loaded and pages fine
<%@dotnet.itags.org. Page Explicit="True" Language="VB" Debug="True" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@dotnet.itags.org. Register TagPrefix="ASPFD" TagName="Header" src="http://pics.10026.com/?src=header.ascx" %>
<%@dotnet.itags.org. import Namespace="System.Data" %>
<%@dotnet.itags.org. import Namespace="System.Data.OleDb" %>
<script runat="server"
' Sub Page_Load(Sender As Object, E As EventArgs)
' Header.AddPageName("Search")
' End SubPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Session("SelectStatement") = "Select * From GolfersQ Order By Lastname"
BindGrid()End If
End Sub
Sub Search_Click(ByVal Sender As Object, ByVal E As EventArgs)
Dim SelectStatement As String
Dim WhereClause As StringMessage.Text = ""
' If they only entered a Lastname, go to the Lastname page
The next snippet of code is from my search page, that works fine, even paging for a while but then suddenly starts erroring out, until I run the original page again, you will see the lines of code i have commented out..
<script runat="server"
Sub Page_Load(Sender As Object, E As EventArgs)
Header.AddPageName("Search")
End Sub' Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' If Not Page.IsPostBack Then
' Session("SelectStatement") = "Select * From GolfersQ Order By Lastname"
' BindGrid()' End If
' End Sub
Sub Search_Click(ByVal Sender As Object, ByVal E As EventArgs)
Dim SelectStatement As String
Dim WhereClause As StringMessage.Text = ""
' If they only entered a Lastname, go to the Lastname page
I know this sounds confusing, its difficult to explain whats going on, but if anybody can point me in the right direction on whats happening, I would be very grateful.
Thanks in advance
SteveIt would probably help if you showed us the error message.
Hi,
Here is the error message im getting
Server Error in '/' Application.
------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 110:
Line 111: Connect.ConnectionString = ConnectString
Line 112: Adapter.SelectCommand = New OleDbCommand(Session("SelectStatement").ToString(), Connect)
Line 113: 'Adapter.SelectCommand.Connection.Open()
Line 114: Adapter.Fill(Top100DS, "GolfersQ")
Source File: D:\Webspace\golfinmanchester.co.uk\wwwroot\search.aspx Line: 112
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP.Search_aspx.BindGrid() in D:\Webspace\golfinmanchester.co.uk\wwwroot\search.aspx:112
ASP.Search_aspx.AdsGrid_Page(Object sender, DataGridPageChangedEventArgs e) in D:\Webspace\golfinmanchester.co.uk\wwwroot\search.aspx:126
System.Web.UI.WebControls.DataGrid.OnPageIndexChanged(DataGridPageChangedEventArgs e) +110
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +349
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +100
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +120
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277
------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
hope this helps you help me !!
Session("SelectStatement") is probably null (Nothing).
0 comments:
Post a Comment