maybe you should post more of your codes so that we may see the problem because it should work if you put the code to populate the control values from database within if page is postback.
Lynn
Please mark replies that have helped you as answers.
If you can read the updated value in btn click function but still u cannot see it updated in backend database , then most probably ur stored proc is not working correctly . Or the logic which you have written to update the values in database.
You've got a comment in your Button_Save_Changes_Click event. A comment doesn't actually do anything, so since you're doing nothing in your code, nothing is being saved to your database. Hope that helps.
I solved the problem another way ... I kept double the no. of textboxes than actually needed ... At the Page_Load event i filled half of them with data and made them uneditable by ButtonX.Enabled=False ... Another half would remain invisible using ButtonX.Visible=False
...
I kept another button in page named 'edit' along with 'Save changes' ... By clicking this button the first half of the textboxes which were filled during Page_Load would become invisible and another half would become visible, will be filled with data and
user can edit the values ... Then when 'Save Changes' button would be pressed the data from these 2nd half textboxes would be sent to database for updating ...
Marked as answer by harshshah0589 on Aug 15, 2009 07:36 PM
harshshah058...
0 Points
3 Posts
Not able to get new value of text box
Aug 15, 2009 11:34 AM|LINK
On my page load event i fill the values in textbox by getting values from database
I want the user to edit the values
These values should be updated on a button click
But the problem is that the new values are not reflected in database
Here is my code :
Protected Sub Page_Load
'Get data from database and display in textbox
End Sub
Protected Sub Button_Save_Changes_Click
'Get values from textbox and update in database
End Sub
On some forums is read that including your Page_load code inside If Not Page.IsPostBack will solve that problem but it's not working for me.
Plz help.
Steelymar
All-Star
15283 Points
2239 Posts
Re: Not able to get new value of text box
Aug 15, 2009 11:59 AM|LINK
When you send a post back(Button_Save_Changes is clicked), the sequence of execution of events is
first Page_Load after that Button_Save_Changes_Click.
if you don't put If Not Page.IsPostBack the TextBox will be charget every time with value from DB.
Protected Sub Page_Load() If Not Page.IsPostBack Then 'Get data from database and display in textbox End If End SubStefan Uzunov
MCTS: .NET Framework 3.5 ASP.NET Applications
harshshah058...
0 Points
3 Posts
Re: Not able to get new value of text box
Aug 15, 2009 12:03 PM|LINK
I already tried this .... It's not working ...
lberan
Contributor
4089 Points
1097 Posts
Re: Not able to get new value of text box
Aug 15, 2009 12:07 PM|LINK
maybe you should post more of your codes so that we may see the problem because it should work if you put the code to populate the control values from database within if page is postback.
Please mark replies that have helped you as answers.
Pawan_Mishra
Star
8869 Points
1293 Posts
Re: Not able to get new value of text box
Aug 15, 2009 12:10 PM|LINK
Hi
If you can read the updated value in btn click function but still u cannot see it updated in backend database , then most probably ur stored proc is not working correctly . Or the logic which you have written to update the values in database.
Pawan Mishra
Moving from Asp.Net to WPF and SilverLight .....
.Net 360°
Talib_dotnet
Contributor
2162 Points
458 Posts
Re: Not able to get new value of text box
Aug 15, 2009 12:23 PM|LINK
Hi Harsha,
Please post your complete code so as to help you out .
Chief Technology Architect
MCTS
OnlineASP.Net
A-S-P Arabia...Consult Us
mendhak
All-Star
17868 Points
2787 Posts
Re: Not able to get new value of text box
Aug 15, 2009 01:08 PM|LINK
Ah, here's your problem:
You've got a comment in your Button_Save_Changes_Click event. A comment doesn't actually do anything, so since you're doing nothing in your code, nothing is being saved to your database. Hope that helps.
harshshah058...
0 Points
3 Posts
Re: Not able to get new value of text box
Aug 15, 2009 07:32 PM|LINK
I solved the problem another way ... I kept double the no. of textboxes than actually needed ... At the Page_Load event i filled half of them with data and made them uneditable by ButtonX.Enabled=False ... Another half would remain invisible using ButtonX.Visible=False ...
I kept another button in page named 'edit' along with 'Save changes' ... By clicking this button the first half of the textboxes which were filled during Page_Load would become invisible and another half would become visible, will be filled with data and user can edit the values ... Then when 'Save Changes' button would be pressed the data from these 2nd half textboxes would be sent to database for updating ...
dk_kawathe
Member
2 Points
1 Post
Re: Not able to get new value of text box
Nov 23, 2012 12:40 PM|LINK
I set breakpoint at Update Function not at page load method i.e the reason i did'nt find problem.
when i click on update values from db assign to textbox again and update with old values again.
I put assign value method in if(!ispostbak){} block
i.e
protected void Page_Load(object sender, EventArgs e) { if(!ispostbak) { //assign values to textbox } }Tip: Anybody have problem like this or others set breakpoint at page load method and debug.
thanks for valuable hint