DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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, 02:18 PM
  2. How to retain session variable
    By NikhilSriv in forum Java
    Replies: 1
    Last Post: 06-14-2006, 05:24 AM
  3. Replies: 0
    Last Post: 08-27-2002, 12:21 PM
  4. Session variable problems
    By Nate in forum Enterprise
    Replies: 2
    Last Post: 10-13-2000, 12:38 PM
  5. Session variable problems
    By Nate in forum ASP.NET
    Replies: 5
    Last Post: 09-01-2000, 03:41 PM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links