Foreground HTML code:
<%@ page language= "C #" autoeventwireup= "true" codefile= "Update.aspx.cs" inherits= "Update"%><! DOCTYPE html> Background C # code:
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class update:system.web.ui.page{protected void Page_Load (object sender, Eve Ntargs e) {if (session["UID"]! = null) {if (! IsPostBack) {Testdatacontext context = new Testdatacontext (); The drop-down list fills in the data Drnation.datasource = context. Nation; Drnation.datatextfield = "Name"; Drnation.datavaluefield = "Code"; Drnation.databind (); Remove the passed code value string code = request["Code"]. ToString (); Check the database Info data = Context.Info.Where (P=>p.code==code). First (); Add the data Txtcode.text =. Code; txtName.Text = data. Name; Txtbirthday.text = data. Birthday.Value.ToString ("Yyyy-mm-dd"); rdman.checked =Data. Sex.value; foreach (ListItem item in Drnation.items) {if (item. Value = = data. Nation) {Item. Selected = true; }}}} else {Response.Redirect ("denglu.aspx"); }} protected void button1_click (object sender, EventArgs e) {testdatacontext context = new Testdataconte XT (); Value string code = Txtcode.text; String name = txtName.Text; bool sex = rdman.checked; String nation = Drnation.selectedvalue; DateTime birthday = Convert.todatetime (txtbirthday.text); This data is found in Info = Context.Info.Where (p = = P.code = = Code). First (); Modify the content data. name = name; Data. sex = sex; Data. Nation = Nation; Data. Birthday = Birthday; Submit the context. SubmitChanges (); } protected void Button2_Click (object sender, EventArgs e) {Response.Redirect ("main.aspx"); }}
Page Display Picture:
WB Example Modification