Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:52:02+00:00 2026-06-12T13:52:02+00:00

I fill textboxes with data that i get from database and put a button

  • 0

I fill textboxes with data that i get from database and put a button on page that user can edit data and click on this button then from code behind i set changes to database

but when i want to send data (for example txtName.Text that source value is “John” and i change it to “Tom”) to database i see txtName.Text is “John” (means last value no new value)

why?

//Load Data
protected void Page_Load(object sender, EventArgs e)
{ 
      DataSet ds = ....
      txtName.Text = ds.Tables[0].Rows[0][1].ToString();
}

//Update
protected void reg_Click(object sender, EventArgs e)
{
     string name=txtName.Text;
     //i change value of txtName.Text but see value as same as value in ds.Tables[0].Rows[0][1].ToString() that i select from DB
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:52:03+00:00Added an answer on June 12, 2026 at 1:52 pm

    This is because you are overwriting the value of the textbox during each request. If you put the code into a if (!IsPostBack) then it will work:

    protected void Page_Load(object sender, EventArgs e)
    {
          if (!IsPostBack)
          {
              DataSet ds = ....
              txtName.Text = ds.Tables[0].Rows[0][1].ToString();
          }
    }
    
    protected void reg_Click(object sender, EventArgs e)
    {
         string name=txtName.Text;
    }
    

    If you place a breakpoint in both Page_Load and reg_Click, then things will become obvious. Page_Load is called on every request. In case of the postback (caused by clicking the button), it is called before the button click handler, and will therefore overwrite the (edited) value of the textbox with the original value read from the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this 8 textboxes that require users to fill in the data in
I have a series of textfields and textboxes that a user can fill out,
So basically, I have a bunch of TextBoxes that the user gets to fill
if(ns1 == '' && ns2 == '') is empty than user will get this
I'm building an application where users can add, edit and delete users from the
I have a field on a form that is hidden but pulls data from
I'm trying to get data from textbox but it says undefined id or something
I have an aspx Page that contain a userControl that contains textboxes. in the
I have two text boxes that I want users to fill with geolocation data
I'm trying to insert data from a form to my database and it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.