Hi,
I've got a search results page that takes information from its query string and displays data in labels and a datagrid. It works well, until you move to a new page then go back to it. When you go back there's an error message.
The current code (first part) is:
The place where I'm getting an error is:
dateFrom = dateFrom.Remove(0, 1)
The error is "Index and Count must refer to a location within the string. Parameter name = count."
Any ideas why this should work first time, but not on post back? The query string is still the same.
Julia
I've got a search results page that takes information from its query string and displays data in labels and a datagrid. It works well, until you move to a new page then go back to it. When you go back there's an error message.
The current code (first part) is:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
dateFrom = Request.QueryString("DateFrom")
dateTo = Request.QueryString("DateTo")
quoteID = CInt(Request.QueryString("QuoteID"))
quoteNo = Request.QueryString("QuoteNo")
customerID = CInt(Request.QueryString("CustID"))
customerName = Request.QueryString("CustName")
partNo = Request.QueryString("PN")
raiserID = Request.QueryString("RaiserID")
raiserName = Request.QueryString("RaiserName")
lifecycle = Request.QueryString("Lifecycle")
breakdown = Request.QueryString("Breakdown")
all = Request.QueryString("All")
If Not Me.IsPostBack Then
'find out what type of user the person is and set the page up as required
'first instance if the user has no permissions then redirect them
Select Case Global.WindowsUser.Level
Case UserPermissionLevel.None
Response.BufferOutput = True
Response.Redirect("PermissionsErrors.aspx?ErrorType=NoPermissions")
'otherwise populate the form
Case UserPermissionLevel.Read, UserPermissionLevel.Edit, UserPermissionLevel.DataAdmin, UserPermissionLevel.SystemAdmin
Me.QuoteSearchDataAdapter.SelectCommand.Connection = Connection
Me.DBCommand.Connection = Connection
'Get all the information needed for the search from the query string
'and populate the search criteria labels for the user
dateFrom = dateFrom.Remove(0, 1)
If dateFrom <> "00/00/00" Then
Dim Day As String = Right(dateFrom, 2)
Dim Month As String = Mid(dateFrom, 6, 2)
Dim Year As String = Left(dateFrom, 4)
dateFromDate = ConvertToDateString(Year, Month, Day)
dateFrom = GetEnglishDateString(dateFrom)
Me.DateFromLabel.Text = dateFrom
Else
Me.DateFromLabel.Text = "N/A"
End If
If dateTo <> "00/00/00" Then
Dim Day As String = Right(dateTo, 2)
Dim Month As String = Mid(dateTo, 6, 2)
Dim Year As String = Left(dateTo, 4)
dateToDate = ConvertToDateString(Year, Month, Day)
dateTo = GetEnglishDateString(dateTo)
Me.DateToLabel.Text = dateTo
Else
Me.DateToLabel.Text = "N/A"
End If
The place where I'm getting an error is:
dateFrom = dateFrom.Remove(0, 1)
The error is "Index and Count must refer to a location within the string. Parameter name = count."
Any ideas why this should work first time, but not on post back? The query string is still the same.
Julia