 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 16th, 2008, 12:01 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 17th, 2008, 07:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
================================================== =========
|
|
 |