Why, why, why???

G

Guest

Hi...

Can someone please tell me why my querystring isn't returning anything!

I have a called viewpage.aspx that contains a datagrid with the following
linkcolumn

<asp:hyperlinkcolumn DataNavigateUrlField="pageid"
DataNavigateUrlFormatString="editor.aspx?id={0}" Text="<img border=0
src=../images/edit.gif alt=Edit Page>">

When I run the code the id is sent to editor.aspx which is visable in the
address bar so I know it is working. However when I try to request the
querystring it returns rowID=0

WHY???

Would appritiate any advice... thanks

CODE..

Private rowID As Integer = 1

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

'Get Text for Editor
If Not Page.IsPostBack Then
rowID = CType(Request.QueryString(ID), Integer)
FreeTextBox1.Text = GetDocument()
End If


End Sub 'Page_Load

Public Sub Button_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
UpdateDocument(FreeTextBox1.Text)
End Sub 'Button_Click

Private Function GetDocument() As String
Dim ds As DataSet = GetDataSet(("SELECT content FROM tblPageContent
WHERE pageID=" + rowID.ToString()))
Dim table As DataTable = ds.Tables(0)
Dim row As DataRow = table.Rows(0)
Dim doc As String = row("content").ToString()
Return doc
ds.Dispose()
End Function 'GetDocument
 
M

Marina

You are indexing by ID. What is ID. Is this a variable you have defined
somewhere? What is its value?

You need to use Request.QueryString("id"), to get the value of the variable
called 'id'.
 
G

Guest

Thanks! I was missing the quotes!


Can you then explain why the variable rowID resets itself to equal nothing
when it hits this function!

Thanks

Private Sub UpdateDocument(ByVal doc As String)
Dim strSQL As String = ""
strSQL += "UPDATE tblPageContent SET content='"
strSQL += (doc.Replace(Chr(39), Chr(39) + Chr(39)))
strSQL += "' WHERE pageID=" + rowID.ToString()
RunQuery((strSQL))
End Sub 'UpdateDocument
 
M

Marina

An integer variable can never be nothing. It can be 0, it will never be a
null reference.

If you are setting the variable to a query string variable that wasn't
found, then casting nothing to an integer will result in your integer
variable being set to 0.

You can't post little separate snippets and ask why the variable got set to
nothing, or anything else. Any number of pieces of code could have run
before this function was hit that could have changed it. We don't know what
you have.
 
P

Patrice

How do you know it's "nothing" ?

Patrice

--

Tim::.. said:
Thanks! I was missing the quotes!


Can you then explain why the variable rowID resets itself to equal nothing
when it hits this function!

Thanks

Private Sub UpdateDocument(ByVal doc As String)
Dim strSQL As String = ""
strSQL += "UPDATE tblPageContent SET content='"
strSQL += (doc.Replace(Chr(39), Chr(39) + Chr(39)))
strSQL += "' WHERE pageID=" + rowID.ToString()
RunQuery((strSQL))
End Sub 'UpdateDocument
 
G

Guest

OK!
Thank you...

Marina said:
An integer variable can never be nothing. It can be 0, it will never be a
null reference.

If you are setting the variable to a query string variable that wasn't
found, then casting nothing to an integer will result in your integer
variable being set to 0.

You can't post little separate snippets and ask why the variable got set to
nothing, or anything else. Any number of pieces of code could have run
before this function was hit that could have changed it. We don't know what
you have.
 
J

Juan T. Llibre

Tim,

although this is an ASP.NET newsgroup, and your
question does constitute an ASP.NET code issue,
did you know that questions about FreeTextBox
coding will probably have a better chance of being
expertly answered at the FreeTextBox Forums ?

http://www.freetextbox.com/forums/




Juan T. Llibre
ASP.NET MVP
===========
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top