•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,571 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,806 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 374 | Replies: 2
![]() |
•
•
Join Date: Dec 2004
Posts: 37
Reputation:
Rep Power: 4
Solved Threads: 0
I have an Access database and I want to fill some text boxes with data from a table. I'm using the following method for an example:
That works great. I have that in the PageLoad event.
Then I want a user to be able to change that value and submit it and have it update the database field.
So to do that, I have something like this:
This, however, doesn't work. It updates the database with the data that's entered into the text boxes on PageLoad instead of what's typed. I have the above code in my button click event.
I've tested my button click event by taking out the fill code in the PageLoad (making empty text boxes) and filling them in and submitting it and the correct information gets updated in the database, so I know that part of the code is correct.
Is there a reason why the button click event is taking the text from PageLoad instead of what's actually typed in the text box?
Me.txtCompany.Text = dr.GetString(1)
That works great. I have that in the PageLoad event.
Then I want a user to be able to change that value and submit it and have it update the database field.
So to do that, I have something like this:
strSQLCompany = "UPDATE Customers SET CompanyName='" & txtCompany.Text.Replace("'", "_") & "'"This, however, doesn't work. It updates the database with the data that's entered into the text boxes on PageLoad instead of what's typed. I have the above code in my button click event.
I've tested my button click event by taking out the fill code in the PageLoad (making empty text boxes) and filling them in and submitting it and the correct information gets updated in the database, so I know that part of the code is correct.
Is there a reason why the button click event is taking the text from PageLoad instead of what's actually typed in the text box?
•
•
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 86
Reputation:
Rep Power: 2
Solved Threads: 6
Have you written your code in IsPostBack method ?
Thanks,
Kusno.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.txtCompany.Text = dr.GetString(1)
End If
Protected Sub CmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdSave.Click
Dim strSQLCompany as String
strSQLCompany = "UPDATE Customers SET CompanyName='" & txtCompany.Text.Replace("'", "_") & "'"
End SubThanks,
Kusno.
NEVER NEVER NEVER GIVE UP
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
- Previous Thread: How can i create ASP.NET Webmail ?
- Next Thread: Novice looking for help!!!!


Linear Mode