How to use session variable with if condition.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to use session variable with if condition.

  1. #1
    Join Date
    Aug 2007
    Posts
    30

    How to use session variable with if condition.

    Hi,
    How to use session variable here with If condition.. When i debug its not getting filled in dataset...Here actually according to USER_LEVEL i have to display records in repeater list.... My code is:
    Code:
    Private Sub ItemsGet()
     Try
         Dim strSQL As String
         ObjConn.Open()
         If Session("USER_LEVEL") = "II" Then
             Dim sda As New SqlDataAdapter("Select ..........where Responsible='" & Session("USER_ID") & "'",ObjConn)
         ElseIf Session("USER_LEVEL") = "III" Then
             Dim sda As New SqlDataAdapter("Select ...........where Type="MIS"",ObjConn)
          ElseIf Session("USER_LEVEL") = "IIII" Then
             Dim sda As New SqlDataAdapter("Select ............... where Type="IT"",ObjConn)
          
        Dim Items As New Dataset
        sda.Fill(Items)
    
       Dim ObjPds as New PagedDataSource
       ObjPds.DataSource = Items.Tables(0).DefaultView
       ObjPds.AllowPaging = True
       ObjPds.PageSize = 5
       ObjPds.CurrentPageIndex=CurrentPage
       Customers.DataSource=ObjPds
       Customers.DataBind()
      EndIf
      ObjConn.Close()
      Catch ex As Exception
      End Try
    End Sub.
    Thanks..
    Yasin.

  2. #2
    Join Date
    Aug 2007
    Location
    London
    Posts
    73
    if condition is working then
    eclare a public variable
    In the page load you give this one

    Public str as string
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    str = Session("USER_LEVEL")

    end sub

    if str = "II" then
    ....
    end if

    where u have to give session values, give that variable
    then use the if condition, i think this will slove ur problm...

Similar Threads

  1. Problem getting session information
    By partyk1d24 in forum AJAX
    Replies: 2
    Last Post: 02-16-2007, 03:18 PM
  2. How to retain session variable
    By NikhilSriv in forum Java
    Replies: 1
    Last Post: 06-14-2006, 06:24 AM
  3. Replies: 0
    Last Post: 08-27-2002, 01:21 PM
  4. Session variable problems
    By Nate in forum Enterprise
    Replies: 2
    Last Post: 10-13-2000, 01:38 PM
  5. Session variable problems
    By Nate in forum ASP.NET
    Replies: 5
    Last Post: 09-01-2000, 04:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center