Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2008, 12:01 AM
Authorized User
 
Join Date: Jan 2008
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query string value

 Hi

i am trying to access the querystring variable in case of Go button cick event but for some reason its empty.



Many Thanks in advance.



Code:
mports System.Data
Imports System.Data.SqlClient

Partial Class News_Listing
    Inherits System.Web.UI.UserControl

    Dim cmd As SqlCommand
    Public CurrentPageNumber As Integer = 1
    Dim totalpages As Double = 1
    Dim totalRecords As Integer = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim ID As New Sitecore.Xml.Xsl.XslHelper
        Dim name As String
        name = ID.qs("Category")


        If Page.IsPostBack = False Then
            ' MsgBox("is true")


            If name <> "" Then
                Dim Category As String = name
                Category = Replace(Category, "-", " ")

                ' DDL_Year.DataSource = loaditems("Year")

                If Request.QueryString("Year") <> "" Then
                    DDL_Year.Text = Request.QueryString("Year")
                End If
                ' DDL_Year.DataBind()

                If Request.QueryString("Month") <> "" Then
                    DDL_Month.Text = Request.QueryString("Month")
                End If

                Dim dt As DataTable
                Dim totalRecords As Integer

                If Request.QueryString("Month") = "" Then
                    dt = BindGvData(CurrentPageNumber, 6, GetCategoryName(Category), 0, 0, totalRecords)
                Else
                    dt = BindGvData(CurrentPageNumber, 6, GetCategoryName(Category), CInt(DDL_Year.SelectedValue), DDL_Month.SelectedValue, totalRecords)
                End If

                Dim i As Integer = totalRecords
                GVListing.DataSource = dt
                GVListing.DataBind()

                Dim totalpages As Double
                totalpages = totalRecords / 6
                totalpages = System.Math.Ceiling(totalpages)
                totalpages = Double.Parse(totalpages)
                Total.Text = totalpages.ToString
                Current.Text = CurrentPageNumber.ToString

                If CInt(Total.Text) >= 1 Then
                    FirstPage.Enabled = True
                    PreviousPage.Enabled = True
                    NextPage.Enabled = True
                    LastPage.Enabled = True

                    If Current.Text <= 1 Then
                        FirstPage.Enabled = False
                        PreviousPage.Enabled = False
                    End If

                ElseIf Total.Text <= 1 Then
                    FirstPage.Enabled = False
                    PreviousPage.Enabled = False
                    NextPage.Enabled = False
                    LastPage.Enabled = True

                End If
                NewsArchivePanel.Visible = True ' make visible if query string contains category

            Else
                NewsArchivePanel.Visible = False
            End If
        Else
            'Dim oldurl As String = Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING")
            'Dim ID As New Sitecore.Xml.Xsl.XslHelper
            ' Dim curl As Uri = Request.Url

            Dim iMonth As String = Request.QueryString("Month") ' ID.qs("Month")


        End If

    End Sub
Public Function BindGvData(ByVal iPage As Integer, ByVal iRecordsPerPage As Integer, ByVal iCategoryName As String, ByVal Year As Integer, ByVal Month As Integer, ByRef TotalRecords As Integer) As DataTable
        iCategoryName = GetCategoryName(iCategoryName)

        Dim con As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
        cmd = New SqlCommand("testNews.dbo.usp_NewsArchivePaging", con)
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add(New SqlParameter("@iPage", SqlDbType.SmallInt)).Value = iPage
        cmd.Parameters.Add(New SqlParameter("@iRecsPerPage", SqlDbType.TinyInt)).Value = iRecordsPerPage 'Set the GVPaging size here
        cmd.Parameters.Add(New SqlParameter("@iCategoryName", SqlDbType.VarChar)).Value = iCategoryName
        cmd.Parameters.Add(New SqlParameter("@iYear", SqlDbType.Int)).Value = Year
        cmd.Parameters.Add(New SqlParameter("@iMonth", SqlDbType.Int)).Value = Month

        cmd.Parameters.Add(New SqlParameter("@iNoRecordsReturned", SqlDbType.Int)).Direction = ParameterDirection.Output
        cmd.Parameters.Add(New SqlParameter("@iMoreRecords", SqlDbType.Int)).Direction = ParameterDirection.Output
        cmd.Parameters.Add(New SqlParameter("@iCountAllNewsInCategory", SqlDbType.Int)).Direction = ParameterDirection.Output

        con.Open()

        Dim dr As SqlDataReader = cmd.ExecuteReader()
        Dim dt As New DataTable()
        dt.Load(dr)
        dr.Close()
        con.Close()

        TotalRecords = CType(cmd.Parameters("@iCountAllNewsInCategory").Value, Integer)
        cmd.Parameters.Clear()
        Return dt

    End Function
Public Sub bind()
        '  Dim totalRecords As Integer '= 0

        Dim al As DataTable
        Dim ID As New Sitecore.Xml.Xsl.XslHelper
        Dim name As String = ID.qs("Category")
        Dim Category As String = name

        If Request.QueryString("Month") = "" Then

            Category = Replace(Category, "-", " ")
            al = BindGvData(CurrentPageNumber, 6, GetCategoryName(Category), DDL_Year.SelectedValue, DDL_Month.SelectedValue, totalRecords)

        Else
            al = BindGvData(CurrentPageNumber, 6, GetCategoryName(Category), DDL_Year.SelectedValue, 0, totalRecords)


        End If


        Dim i As Integer = totalRecords

        GVListing.DataSource = al
        DataBind()
        Dim totalpages As Double
        If Page.IsPostBack Then
            totalpages = totalRecords / 6
            totalpages = System.Math.Ceiling(totalpages)
        Else
            totalpages = Double.Parse(totalpages)
        End If
        Total.Text = totalpages.ToString
        Current.Text = CurrentPageNumber.ToString
        ' i took the ShowCategories() from here
    End Sub

    Public Sub UpdateURL()

        Dim ID As New Sitecore.Xml.Xsl.XslHelper
        Dim name As String = ID.qs("Category")
        Dim Category As String = name

        Dim oldurl As String = Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING")
        'Dim s(30) As String
        's = oldurl.Split("/")
        Dim Year As String = DDL_Year.SelectedItem.Text
        Dim Month As String = DDL_Month.SelectedItem.Text
        'Dim newurl As String = "http://localhost" & oldurl & "&Month=" + DDL_Month.SelectedItem.Text & "&Year=" & DDL_Year.SelectedItem.Text
        Dim newurl As String = "http://localhost:3920/test_NewsArchive/default.aspx?Category=" & name & "&Year=" & Year & "&Month=" & Month

        Response.Redirect(newurl)
    End Sub



    Protected Sub Bt_Go_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Bt_Go.Click
        ' bind()
        UpdateURL()
    End Sub
End Class
Reply With Quote
  #2 (permalink)  
Old March 17th, 2008, 07:27 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

so, what's your problem?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query string problem sathish_reddy ASP.NET 2.0 Basics 0 February 23rd, 2007 08:18 AM
How to encode query string gurudatta_shelke General .NET 0 August 1st, 2006 05:55 AM
Query String Baby_programmer ASP.NET 1.0 and 1.1 Basics 3 December 24th, 2004 11:14 AM
Query String Nitin_sharma VBScript 1 December 16th, 2004 07:58 AM
Query String not working!!!!!!! cmiller Beginning PHP 1 December 16th, 2003 12:30 PM



All times are GMT -4. The time now is 10:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.