Background:
Public Partial classupdate:system.web.ui.page{PrivateTextdatacontext context =NewTextdatacontext (); protected voidPage_Load (Objectsender, EventArgs e) { if(session["UID"] !=NULL) { if(!IsPostBack) { //bind data to a national drop-down listDrnation.datasource =context. Nation; Drnation.datatextfield="Name"; Drnation.datavaluefield="Code"; Drnation.databind (); //take primary key value stringCode = request["Code"]. ToString (); //Check the databaseInfo data = context.Info.Where (p = = P.code = =code). First (); //fill in the dataTxtcode.text =data. Code; txtName.Text=data. Name; Txtbirthday.text= data. Birthday.Value.ToString ("yyyy mm month DD Day"); if(Data. Sex = =true) {Rdnan. Checked=true; } Else{RDNV. Checked=true; } foreach(ListItem Iteminchdrnation.items) {if(item. Value = =data. Nation) {Item. Selected=true; } } } } Else{Response.Redirect ("denglu.aspx"); } } protected voidButton1_Click (Objectsender, EventArgs e) { //find this data .Info data = context.Info.Where (p = = P.code = =txtcode.text). First (); //Modify ContentData. Name =txtName.Text; Data. Sex=Rdnan. Checked; Data. Nation=Drnation.selectedvalue; Data. Birthday=Convert.todatetime (Txtbirthday.text); //Submitcontext. SubmitChanges (); } protected voidButton2_Click (Objectsender, EventArgs e) {Response.Redirect ("main.aspx"); }
20151221:web Review: Modify