Reassign value to private

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltOjouLg==?=, Jan 27, 2005.

  1. Hi Can some one please tell me how I re assign a value to a private variable
    with a querystring!

    I want to do something like this!

    Private rowID As Integer = request.querystring(id)

    However this doesn't work!

    Would really appritiate anyhelp!

    Thanks

    ... Current 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
    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 * 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
    End Function 'GetDocument
     
    =?Utf-8?B?VGltOjouLg==?=, Jan 27, 2005
    #1
    1. Advertising

  2. Querystring is a string. rowID is integer. You need to convert a string to
    an integer. Example:

    rowID = System.Convert.ToInt32 (request.querystring(id))

    Eliyahu

    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > Hi Can some one please tell me how I re assign a value to a private

    variable
    > with a querystring!
    >
    > I want to do something like this!
    >
    > Private rowID As Integer = request.querystring(id)
    >
    > However this doesn't work!
    >
    > Would really appritiate anyhelp!
    >
    > Thanks
    >
    > .. Current 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
    > 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 * 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
    > End Function 'GetDocument
     
    Eliyahu Goldin, Jan 27, 2005
    #2
    1. Advertising

  3. Why do I then get

    Error:
    There is no row at position 0.

    I presume it is because GetDocument() is being executed before rowID has a
    value!
    How can I change this???

    Thanks


    "Eliyahu Goldin" wrote:

    > Querystring is a string. rowID is integer. You need to convert a string to
    > an integer. Example:
    >
    > rowID = System.Convert.ToInt32 (request.querystring(id))
    >
    > Eliyahu
    >
    > "Tim::.." <myatix_at_hotmail.com> wrote in message
    > news:...
    > > Hi Can some one please tell me how I re assign a value to a private

    > variable
    > > with a querystring!
    > >
    > > I want to do something like this!
    > >
    > > Private rowID As Integer = request.querystring(id)
    > >
    > > However this doesn't work!
    > >
    > > Would really appritiate anyhelp!
    > >
    > > Thanks
    > >
    > > .. Current 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
    > > 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 * 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
    > > End Function 'GetDocument

    >
    >
    >
     
    =?Utf-8?B?VGltOjouLg==?=, Jan 27, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. biswaranjan.rath

    how to reassign variable

    biswaranjan.rath, May 5, 2006, in forum: XML
    Replies:
    3
    Views:
    7,807
    biswaranjan.rath
    May 5, 2006
  2. Shailesh Humbad

    reassign keys in an STL map

    Shailesh Humbad, Oct 29, 2004, in forum: C++
    Replies:
    7
    Views:
    2,608
    Greg Schmidt
    Nov 2, 2004
  3. Bernhard Merkle

    reassign to builtin possible !?

    Bernhard Merkle, Jan 3, 2008, in forum: Python
    Replies:
    8
    Views:
    304
    Bernhard Merkle
    Jan 4, 2008
  4. Immortal Nephi

    Reassign two objects to one pointer?

    Immortal Nephi, May 19, 2009, in forum: C++
    Replies:
    1
    Views:
    321
    Bart van Ingen Schenau
    May 20, 2009
  5. John O'Hagan
    Replies:
    6
    Views:
    362
    John O'Hagan
    Feb 12, 2011
Loading...

Share This Page