473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Problem with Postback

Hi. Could anyone help me please?

I am stuck with a problem that I do not know how to solve it. I have a main page and a user control inside it. In the main page I have the fields stationId and readingDate. The code for main page is:

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.   DateTime readingDate;
  4.   try
  5.   {
  6.     readingDate = new DateTime(int.Parse(DDLYear.SelectedValue), int.Parse(DDLMonth.SelectedValue), int.Parse(DDLDay.SelectedValue));
  7.   }
  8.   catch
  9.   {
  10.      readingDate = DateTime.Now;
  11.   }
  12.   FCRDieselLabAnalysisModule1.StationId = int.Parse(BDDLStation.SelectedValue);
  13.   FCRDieselLabAnalysisModule1.ReadingDate = readingDate;
  14. }
  15.  
  16. In the user control I have set the StationId and ReadingDate properties and the following code in it:
  17.  
  18. public int StationId
  19. {
  20.   get
  21.   {
  22.     return stationId;
  23.   }
  24.   set
  25.   {
  26.     stationId = value;
  27.   }
  28. }
  29.  
  30. public DateTime ReadingDate
  31. {
  32.   get
  33.   {
  34.     return readingDate;
  35.   }
  36.   set
  37.   {
  38.     readingDate = value;
  39.   }
  40. }
  41.  
  42. protected void Page_Load(object sender, EventArgs e)
  43. {
  44.   FuelLabAnalysisDataTDS fuelLabAnalysisData;
  45.   fuelLabAnalysisData = new FuelLabAnalysis ().GetFuelLabAnalysisByStationIdAndReadingDate(stationId, readingDate);
  46.   PopulateTextBoxes(fuelLabAnalysisData);
  47.   if (!IsPostBack)
  48.   {
  49.   }
  50. }
Now the problem I am facing:

When I choose another station or readingDate, it gets the record for those conditions and populate the values to the textboxes inside the user control, which is right. The problem comes when I edit the record, change the textboxes values and click on the BCalculate button (yes, I need to do some calculations with the data), then the GetFuelLabAnalysisByStationIdAndReadingDate() function fires and fill back again with the values currently saved on the DB.
If I call the function inside "if(!IsPostBack){}" block, the problem I have then is when I change the stationId or readingDate conditions, I won't be able to populate the user control because the function to populate it is not fired.

Could anyone please help me, because I have no idea how to solve this issue and I have been for a while with this stuff.

Thanks,
Marco
Dec 15 '10 #1
0 1284

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph Luner | last post by:
I am having problem postback, (code shown below) the variable "my_str" is lost after clicking the "submit" button. Isn't it suppose to display "changed" after posting back? Is there anyway I...
3
by: Igor Belagorudsky | last post by:
Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to do), it throws an obect not found exception on...
0
by: Xavier Osa | last post by:
Hi, I have an ASP.Net web page that you can download a file. As Fergunson's problem, it prompts twice dialog boxes only if I select Open button. If I select Save button, it prompts once. I'm...
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
6
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
1
by: Jason | last post by:
I have a webpage that I've wrapped in an Atlas UpdatePanel. This page contains four textboxes, each with AutoPostBack set to true. The problem comes when someone edits the first box and tabs to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.