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
- protected void Page_Load(object sender, EventArgs e)
- {
- DateTime readingDate;
- try
- {
- readingDate = new DateTime(int.Parse(DDLYear.SelectedValue), int.Parse(DDLMonth.SelectedValue), int.Parse(DDLDay.SelectedValue));
- }
- catch
- {
- readingDate = DateTime.Now;
- }
- FCRDieselLabAnalysisModule1.StationId = int.Parse(BDDLStation.SelectedValue);
- FCRDieselLabAnalysisModule1.ReadingDate = readingDate;
- }
- In the user control I have set the StationId and ReadingDate properties and the following code in it:
- public int StationId
- {
- get
- {
- return stationId;
- }
- set
- {
- stationId = value;
- }
- }
- public DateTime ReadingDate
- {
- get
- {
- return readingDate;
- }
- set
- {
- readingDate = value;
- }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- FuelLabAnalysisDataTDS fuelLabAnalysisData;
- fuelLabAnalysisData = new FuelLabAnalysis ().GetFuelLabAnalysisByStationIdAndReadingDate(stationId, readingDate);
- PopulateTextBoxes(fuelLabAnalysisData);
- if (!IsPostBack)
- {
- }
- }
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