Re: session variable issue?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mike (Mike_at_discussions.microsoft.com)
Date: 10/11/04


Date: Mon, 11 Oct 2004 08:27:05 -0700

they are on the same page for the reason being that I need to post back to
myself to get the users selection from the datalist, then pass only the items
selected to the detail page via a querystring. ( in which i'm also have an
issue with in .NET with this particular one.)

here is the button code snippet
For I = 0 To datalist.Items.Count - 1
            checkBox= dlScores.Items(I).FindControl("chkCars")
            carMake= dlScores.Items(I).FindControl("carmake")
            cbValue = cbValue & checkbox.Checked.ToString()
            If checkbox.Checked.ToString = True Then
                 carMake= carMake & carmake.Text.ToString() & "|"
            End If
        Next
      response.redirect("cardetails.aspx?car=" & carMake)

this is the function that loops thru the datalist and gets me all the cars
selected then pass only them to the detail page.

Is there an easier way to do this? I only want this to fire when the button
is clicked by the user. Also with the querystring if i have the string
seperated with | it will not work, even if i split the string. though it will
work if i remove the | and only select one car in the datalist

"William F. Robertson, Jr." wrote:

> Mike,
>
> Are these code snippets on the same page? If so, then it will not work this
> way. The Button click event is fired after Page_Load. So the session will
> be Nothing as it has not been set yet. Typically you would show action is
> response to a Button Click event, or you can just check the CheckBox
> directly in page load, depending on what else you have going during your
> page execution.
>
> If the code is on two different pages, how are you transfering the user to
> the other page. Response.Redirect, Server.Transfer, Execute?
>
> bill
>
> "Mike" <Mike@discussions.microsoft.com> wrote in message
> news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@microsoft.com...
> > I made the change you requested but i'm still having the same issue?
> >
> > the session varaible is coming back blank
> >
> > on the page where i'm setting the variable.
> > sub page_load
> > if page.ispostback then
> > if session("selection") = "Y" then 'this is sitll coming back as
> > nothing
> > response.write("You selected the following" & " " & cars)
> > end if
> > end if
> >
> > im the button click routine
> > if CurrentCheckBox.Checked = True Then
> > Dim cars As String
> > selectedCars= "Y"
> > Session("selection") = selectedCars
> > End If
> >
> >
> >
> > "William F. Robertson, Jr." wrote:
> >
> > > You are never assigning Session("Selection") to anything.
> > >
> > > You are setting the string "cars" to 'Y', but since never assign the
> Session
> > > it will not work the way you want. I can give a more detailed
> explaination
> > > if you need one, but for now reverse your code like so:
> > >
> > > 'do not call .ToString() on this, just use the bool value checkd
> > > if checkbox.checked = true then
> > > dim cars as string
> > > cars = "Y"
> > > Session("selection") = cars
> > > end if
> > >
> > > Then you code on the next page will work as you are hoping for it to
> work.
> > >
> > > bill
> > >
> > > "Mike" <Mike@discussions.microsoft.com> wrote in message
> > > news:3C57CB24-247E-433D-8971-D2E4E7CE3859@microsoft.com...
> > > > I have a function that is called when the user clicks the submit
> button,
> > > > during this function i also set a varaible to "Y" due to that this
> > > function
> > > > does a post back to the page then redirects. When I look for the
> session
> > > > variable in the page.isPostBack section it equals nothing, it appears
> > > that
> > > > the variable is not being passed to the post back section correctly. I
> > > have
> > > > this due to I only want this function to run if the user has something
> > > > selected in the grid.
> > > >
> > > > code:
> > > > if checkbox.checked.tostring() = true then
> > > > dim cars as string = session("selection")
> > > > cars = "Y"
> > > > end if
> > > >
> > > > in the post back
> > > > if page.isPostback
> > > > if session("selection") = "Y" then 'this equals nothing I debugged
> it
> > > and
> > > > its getting set in the function but being passed as NOTHING
> > > > run Function
> > > > end if
> > > > end if
> > > >
> > > >
> > > >
> > >
> > >
> > >
>
>
>



Relevant Pages

  • Re: SQL Server - Filter
    ... I use PostrgeSQL server as ... procedure that delets these session records on application closing. ... > make a selection from none or some or all of the lists. ... > for each currently logged on user with the filter selections in the table ...
    (comp.databases.ms-access)
  • Re: How to differentiate multiple sessions?
    ... > previous pages to change selection. ... > for this or I should use other stratagies (DB session?) to get things ... no point in going for custom DB session handlers for ... Either use the custom session handler functions built into PHP or put the ...
    (comp.lang.php)
  • RE: How do I open a new window select from dropdownlist?
    ... But remember to clear the session after you retrieve the value, ... Since your drop down list is a server control, ... > javascript...When a user clicks on a selection from a dropdownlist, ... > open a different page in a new window (while keeping the original window ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: State of the asp.net web-page
    ... you have to put selected listbox values into session, ... further selection is possible from the other listboxes. ... >>> when I get back to the original page all my selection of the Listboxes ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Controlling the execution sequence of dependant jobs in JES2 (a suggested fix)
    ... This can result in a job with a /*AFTER statement for a prior job you think JES2 has already seen and processed because of the sequence in the submitted member, being processed and initiated before JES2 ever finishes reading the job that is the object of the /*AFTER statement. ... The /*CNTL XEQ statement is used to add an additional job selection ... and CDE are currently in execution with the ... The condition is satisfied even if the jobname that must be ...
    (bit.listserv.ibm-main)