A better way would be to implement as follows:
Accept a QueryString parameter "
CustomerId
" in
AddNewCustomerPage.aspx.cs
. If the parameter value (
CustomerId
) is greater than 0, retrieve the Customer from the database using the
CustomerId
and set the customer properties in the text boxes. Otherwise, just show the text boxes.
You don't need to use the "
NEW
" or "
EDIT
" mode.
That is, you just implement the following logic in the
Page_Load
of
AddNewCustomerPage.aspx.cs
int CustomerId = 0;
if(Request.Params["CustomerId"] != null)
{
CustomerId = Convert.ToInt32(Request.Params["CustomerId"]);
}
if(CustomerId > 0)
{
Customer customer = GetCustomerFromDB(CustomerId)
PopulateUI(customer);
}