protected void Submit_Click(object sender, EventArgs e) { CleanUpInput(); // 1) Create an object to hold information from the user. if (IsValid && OtherValidation()) { BankAccount Account; Account = new BankAccount(); // 2) Take the info the user entered into the form and put it in the object Account.AccountHolder = AccountHolder.Text; Account.AccountNumber = Convert.ToInt32(AccountNumber.Text); Account.Openingbalance = Convert.ToDouble(OpeningBalance.Text); Account.OverDraftLimit = Convert.ToDouble(OverdraftLimit.Text); Account.AccountType = AccountType.SelectedValue; // 3) Do something with the object // Put the output on the webpage, just to show that we were able to create an object ShowTheFormResult(Account); //add the new account to my StoredData and then display it in the GridView StoredData.Add(Account); BankAccountsGridView.DataSource = StoredData; // give the gridview the data BankAccountsGridView.DataBind(); //tell teh gridview to extract data fro display } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //show whatever data we have in the gridview BankAccountsGridView.DataSource = StoredData; BankAccountsGridView.DataBind(); } }