WB Example Modification

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.