Results 1 to 3 of 3

Thread: dont know whats happening.... plz help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2004
    Posts
    134

    dont know whats happening.... plz help

    hi i am using asp.net..
    in my aspx file i have declared this code in the page directive for output cache

    Code:
    <%@ Outputcache duration="60" varybyparam="state" %>
    i have added this table to my aspx page i also have a datagrid
    VB Code:
    1. <table cellspacing="0" cellpadding="3" rules="all" style="BORDER-LEFT-COLOR:black;BORDER-BOTTOM-COLOR:black;WIDTH:700px;BORDER-TOP-COLOR:black;BORDER-COLLAPSE:collapse;BACKGROUND-COLOR:#aaaadd;BORDER-RIGHT-COLOR:black">
    2.                 <tr>
    3.                     <td><a href="webform1.aspx?state=germany">germany</a></td>
    4.                     <td><a href="webform1.aspx?state=mexico">mexico</a></td>
    5.                     <td><a href="webform1.aspx?state=uk">uk</a></td>
    6.                     <td><a href="webform1.aspx?state=sweden">sweden</a></td>
    7.                     <td><a href="webform1.aspx?state=canada">canada</a></td>
    8.                     <td><a href="webform1.aspx?state=france">france</a></td>
    9.                     <td><a href="webform1.aspx?state=italy">italy</a></td>
    10.                     <td><a href="webform1.aspx?state=portugal">portugal</a></td>
    11.                 </tr>
    12.             </table>
    in my aspx.vb file i have this code

    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         'Put user code to initialize the page here
    3.  
    4.         querystate = Request.QueryString("state")
    5.         If querystate Is Nothing Then
    6.            
    7.             str = "SELECT * From Customers"
    8.         Else
    9.             str = "SELECT * From Customers Where Customers.Country= ' " + querystate + " '  "
    10.         End If
    11.  
    12.         Dim adapt As New OleDbDataAdapter(str, myconn)
    13.         Dim ds As New DataSet
    14.         adapt.Fill(ds, "Customers")
    15.         DataGrid1.DataSource = ds.Tables("customers").DefaultView
    16.         DataGrid1.DataBind()
    17.     End Sub

    when the page loads my datagrid populates and even my table but
    when i am clicking a link from the table which i have in the aspx file nothing shows up in my datagrid .. i have been on this for hours and dont know why.. can someone please explain this to me .. thanks guys...

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: dont know whats happening.... plz help

    Okay try putting in something like this just inside your Page_Load()

    VB Code:
    1. Response.Write(":" & Request.QueryString("state") & ":")
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2004
    Posts
    134

    Re: dont know whats happening.... plz help

    hi thanks.. it worked fine i added it like this

    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         'Put user code to initialize the page here
    3.  
    4.         querystate = Request.QueryString("state")
    5.  
    6.         If querystate Is Nothing Then
    7.            
    8.             str = "SELECT * From Customers"
    9.         Else
    10.  
    11.             str = "SELECT * From Customers Where Customers.Country= '" & Request.QueryString("state") & "'"
    12.         End If
    13.  
    14.         Dim adapt As New OleDbDataAdapter(str, myconn)
    15.         Dim ds As New DataSet
    16.         adapt.Fill(ds, "Customers")
    17.         DataGrid1.DataSource = ds.Tables("customers").DefaultView
    18.         DataGrid1.DataBind()
    19.        
    20.     End Sub

    just one quick question i would like to ask... why wasnt it not working for me when i was putting the variable querystring equal to the sql statement meaning like this.. thanks in advance...

    VB Code:
    1. querystate = Request.QueryString("state")
    2.  
    3.         If querystate Is Nothing Then
    4.            
    5.             str = "SELECT * From Customers"
    6.         Else
    7.  
    8.             str = "SELECT * From Customers Where Customers.Country= '" & Request.QueryString("state") & "'"
    9.         End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width