web form application , create read update delete
HejIgang med et skole projekt og har svært ved at få "update" delen til at virke. Bruger Visual Studio 2012 Express.
Jeg har 3 dataklasser, 1 parentclass "Person.cs" som er abstract. Og så 2 child klasser "Agent.cs" og "Scoundrel.cs". De har begge en masse variables som de arver fra Person.
Create og Read delen fungerer fint.
Her er et uddrag fra update.aspx.cs som driller (Agent objektet skabes fint, det er selve det at gemme den opdaterede version over den gamle version som driller)
Agent myAgent = new Agent(
txtAgentFirstName.Text,
txtAgentLastName.Text,
txtAgentCodename.Text,
Convert.ToInt32(txtAgentPassport.Text),
txtAgentNationality.Text,
txtAgentCountry.Text,
Convert.ToInt32(txtAgentZipcode.Text),
txtAgentCity.Text,
txtAgentAddress.Text,
Convert.ToInt32(txtAgentHeight.Text),
DropDownListHairColorAgent.SelectedValue,
DropDownListEyeColorAgent.SelectedValue,
txtAgentSpecialMarkings.Text,
txtAgentGroupAssociation.Text,
txtAgentPhotoFilename.Text,
Convert.ToInt32(txtAgentPersonelNumber.Text),
licencesArrayList
);
//find matching agent object in the agentArrayList
for(int i=0; i < (Application["MyAgent"] as ArrayList).Count; i++)
{
Agent agentInList = (Application["MyAgent"] as ArrayList)[i] as Agent;
if (myAgent._Id == agentInList._Id)
{
//overwriting whatever content input form for
//agent has filled in, in the corresponding
//agent object already saved in agentArrayList
//saving the work to the application object ["MyAgent"]
Application.Lock();
(Application["MyAgent"] as ArrayList)[i] = myAgent;
Application.UnLock();
}
}
ClearTextBoxes(formCreateMaster);