Problems with Webform textbox

Discussion in 'ASP .Net Web Controls' started by Jeffery J. Morgan, Jun 8, 2004.

  1. If anyone has an idea about this, I am open to suggestions....

    I have a webform that has a textbox. I set it's text property in the page
    load area to data that is in the a dataset, but not bound to the text box. I
    use a data row, get the value and then set the text property to the value
    of the data row.

    It is a data entry application. I have a button on the form that will save
    the data back to the database, but when I go to get the text property of the
    textbox, it always have the initial value and doesn't see what is entered in
    the text box. I am not sure why it doesn't see the updated or change entries
    in the text box.

    Thanks in advanced.

    Jeff
     
    Jeffery J. Morgan, Jun 8, 2004
    #1
    1. Advertising

  2. Hi Jeff,

    Make sure that you aren't refilling the text value on postbacks in the page
    load event. Just wrap that part in If not ispostback() .

    Ken

    "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in message
    news:...
    > If anyone has an idea about this, I am open to suggestions....
    >
    > I have a webform that has a textbox. I set it's text property in the page
    > load area to data that is in the a dataset, but not bound to the text box.
    > I
    > use a data row, get the value and then set the text property to the value
    > of the data row.
    >
    > It is a data entry application. I have a button on the form that will save
    > the data back to the database, but when I go to get the text property of
    > the
    > textbox, it always have the initial value and doesn't see what is entered
    > in
    > the text box. I am not sure why it doesn't see the updated or change
    > entries
    > in the text box.
    >
    > Thanks in advanced.
    >
    > Jeff
    >
    >
     
    Ken Cox [Microsoft MVP], Jun 8, 2004
    #2
    1. Advertising

  3. Hi Ken,

    Thanks for that, but I am filling in the data during a postback. Maybe I
    need to find another way, but the form is painted, the user makes a choice
    from a listbox and then the value is filled in during the postback. Is there
    another way that I am to do this?

    Thanks
    Jeff


    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hi Jeff,
    >
    > Make sure that you aren't refilling the text value on postbacks in the

    page
    > load event. Just wrap that part in If not ispostback() .
    >
    > Ken
    >
    > "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in message
    > news:...
    > > If anyone has an idea about this, I am open to suggestions....
    > >
    > > I have a webform that has a textbox. I set it's text property in the

    page
    > > load area to data that is in the a dataset, but not bound to the text

    box.
    > > I
    > > use a data row, get the value and then set the text property to the

    value
    > > of the data row.
    > >
    > > It is a data entry application. I have a button on the form that will

    save
    > > the data back to the database, but when I go to get the text property of
    > > the
    > > textbox, it always have the initial value and doesn't see what is

    entered
    > > in
    > > the text box. I am not sure why it doesn't see the updated or change
    > > entries
    > > in the text box.
    > >
    > > Thanks in advanced.
    > >
    > > Jeff
    > >
    > >

    >
     
    Jeffery J. Morgan, Jun 8, 2004
    #3
  4. Hi Jeff,

    Could you provide a small sample of code that exhibits the problem? This
    shouldn't be too hard.

    Ken

    "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in message
    news:...
    > Hi Ken,
    >
    > Thanks for that, but I am filling in the data during a postback. Maybe I
    > need to find another way, but the form is painted, the user makes a choice
    > from a listbox and then the value is filled in during the postback. Is
    > there
    > another way that I am to do this?
    >
    > Thanks
    > Jeff
    >
    >
    > "Ken Cox [Microsoft MVP]" <> wrote in message
    > news:...
    >> Hi Jeff,
    >>
    >> Make sure that you aren't refilling the text value on postbacks in the

    > page
    >> load event. Just wrap that part in If not ispostback() .
    >>
    >> Ken
    >>
    >> "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in message
    >> news:...
    >> > If anyone has an idea about this, I am open to suggestions....
    >> >
    >> > I have a webform that has a textbox. I set it's text property in the

    > page
    >> > load area to data that is in the a dataset, but not bound to the text

    > box.
    >> > I
    >> > use a data row, get the value and then set the text property to the

    > value
    >> > of the data row.
    >> >
    >> > It is a data entry application. I have a button on the form that will

    > save
    >> > the data back to the database, but when I go to get the text property
    >> > of
    >> > the
    >> > textbox, it always have the initial value and doesn't see what is

    > entered
    >> > in
    >> > the text box. I am not sure why it doesn't see the updated or change
    >> > entries
    >> > in the text box.
    >> >
    >> > Thanks in advanced.
    >> >
    >> > Jeff
    >> >
    >> >

    >>

    >
    >
     
    Ken Cox [Microsoft MVP], Jun 8, 2004
    #4
  5. Goes something like this...

    if not .ispost back then
    'fill in a list box with choices
    txtcomments.visible=false

    else
    'select the data for the record choose...

    Dim cmdComments As New OleDb.OleDbCommand("Select * from tblcomment
    where permnum='" & strPermnum & "' and term=4", cn)
    Dim dsComments As New DataSet
    Dim daComments As New OleDb.OleDbDataAdapter(cmdComments)
    dacomments.Fill(dsComments, "comments")
    Dim drComments As DataRow
    If dsComments.Tables(0).Rows.Count > 0 Then
    dr = dsComments.Tables(0).Rows(0)
    txtComments.Text = dr.Item("Comment")
    Else
    txtComments.Text = ""
    End If

    DataGrid1.PageSize = 50
    DataGrid1.DataSource = ds
    DataGrid1.DataBind()

    endif


    In the btnSave routine....

    Dim cmdo1 As New OleDb.OleDbCommand("Delete * from tblcomment where
    permnum='" & strPermnum & "' and term=4", cnAccess)

    cmdo1.ExecuteNonQuery()


    cmdo1.CommandText = "Insert into tblcomment (Permnum, Comment, term) values
    ('" & strPermnum & "','" & txtcomments.Text & "', 4)"

    cmdo1.ExecuteNonQuery()

    cnAccess.Close()

    Response.Redirect("frmstudent.aspx")



    In the last routine, the txtcomments.text is the original value that was put
    into it in the postback.



    Thanks

    Jeff



    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hi Jeff,
    >
    > Could you provide a small sample of code that exhibits the problem? This
    > shouldn't be too hard.
    >
    > Ken
    >
    > "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in message
    > news:...
    > > Hi Ken,
    > >
    > > Thanks for that, but I am filling in the data during a postback. Maybe

    I
    > > need to find another way, but the form is painted, the user makes a

    choice
    > > from a listbox and then the value is filled in during the postback. Is
    > > there
    > > another way that I am to do this?
    > >
    > > Thanks
    > > Jeff
    > >
    > >
    > > "Ken Cox [Microsoft MVP]" <> wrote in message
    > > news:...
    > >> Hi Jeff,
    > >>
    > >> Make sure that you aren't refilling the text value on postbacks in the

    > > page
    > >> load event. Just wrap that part in If not ispostback() .
    > >>
    > >> Ken
    > >>
    > >> "Jeffery J. Morgan" <jmorgan@_tranquilitysolutions.com> wrote in

    message
    > >> news:...
    > >> > If anyone has an idea about this, I am open to suggestions....
    > >> >
    > >> > I have a webform that has a textbox. I set it's text property in the

    > > page
    > >> > load area to data that is in the a dataset, but not bound to the text

    > > box.
    > >> > I
    > >> > use a data row, get the value and then set the text property to the

    > > value
    > >> > of the data row.
    > >> >
    > >> > It is a data entry application. I have a button on the form that will

    > > save
    > >> > the data back to the database, but when I go to get the text property
    > >> > of
    > >> > the
    > >> > textbox, it always have the initial value and doesn't see what is

    > > entered
    > >> > in
    > >> > the text box. I am not sure why it doesn't see the updated or change
    > >> > entries
    > >> > in the text box.
    > >> >
    > >> > Thanks in advanced.
    > >> >
    > >> > Jeff
    > >> >
    > >> >
    > >>

    > >
    > >

    >
     
    Jeffery J. Morgan, Jun 8, 2004
    #5
  6. Jeffery J. Morgan

    Sven Guest

    When you set the value every time Page_Load is called, you will always
    see the
    initial value, when a callback function is called. Use Page.IsPostBack
    to set the value only, when Page_Load is called the first time.
     
    Sven, Jun 8, 2004
    #6
    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. Hazzard
    Replies:
    2
    Views:
    549
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    459
    Natty Gur
    Jul 22, 2003
  3. titof
    Replies:
    0
    Views:
    508
    titof
    Jul 24, 2003
  4. timmso
    Replies:
    1
    Views:
    487
    Alex Papadimoulis
    Dec 12, 2003
  5. AGSHAR
    Replies:
    1
    Views:
    592
    AGSHAR
    May 31, 2008
Loading...

Share This Page