Reputation: 60821
i have an asp.net webform where the user can enter data and submit into a database table on sql-server-2008
here is how i grab data from the userform:
public LOMDLL.Main_Lom_Form PopulateMainForm()
{
//populate class
LOMDLL.Main_Lom_Form TheForm = new LOMDLL.Main_Lom_Form();
try
{
TheForm.received_date = received_dateTextbox.Text.ToDateTime();
TheForm.site_of_occurrence = site_of_occurrenceTextBox.Text.ToUpper();
TheForm.occurrence_date = occurrence_dateTextBox.Text.ToDateTime();
TheForm.report_by = report_byTextBox.Text;
if (RadioButtonList1.SelectedValue != "Other:")
TheForm.identified_by = RadioButtonList1.SelectedValue;
else
TheForm.identified_by = "Other: " + otherTextBox.Text;
TheForm.practice_code = txtPracticeCode.Text.ToUpper();
TheForm.comments = txtComments.Text;
TheForm.report_date = report_dateTextBox.Text.ToDateTime();
//TheForm.windows_user = WindowsIdentity.GetCurrent().Name;
TheForm.windows_user = HttpContext.Current.User.Identity.Name.ToString();
TheForm.computer_name = System.Environment.MachineName;
TheForm.time_stamp = DateTime.Now;
}
catch (Exception e)
{
}
return TheForm;
}
it is returning OLD data. it returns what was in the fields BEFORE the user updated the data in the textboxes.
another words when i debug, and i look at the values that are being stored in the textboxes they DO NOT reflect the changes made by the user. the values are the same as they are currently in the database before the update!
what am i doing wrong?
is there some kind of disconnect between client and server?
Upvotes: 0
Views: 176
Reputation: 7713
I would check your bindings when you load the page. Chances are you are re-binding your page from your database before you try to read the changed values.
Check your Page_Load and make sure you are only binding your page with database information when !Page.IsPostBack and not every time you load your page.
Upvotes: 4