Webform---Modify personnel information

Source: Internet
Author: User

 Public Partial classedit:system.web.ui.page{PrivateMydbdatacontext _context =NewMydbdatacontext (); //Bound Nation    Private voidfillnation () {List<Nation> list =_context.nation.tolist (); Txtnation.datasource=list; Txtnation.datatextfield="Name"; Txtnation.datavaluefield="Code";    Txtnation.databind (); }    //in the Modify page get people primary key value load people information    Private voidFillloadinfo () {stringCode = request["ID"]; varquery = _context.info.where (p = = P.code = =Code); if(Query. Count () >0) {Info data=query.            First (); Txtcode.text=data.            Code; txtName.Text=data.            Name; Txtsex.selectedvalue=data.            Sex.tostring (); Txtnation.selectedvalue=data.            Nation; Txtbirthday.text= data. Birthday.Value.ToString ("yyyy mm month DD Day"); }    }    //loading national and personal information    protected voidPage_Load (Objectsender, EventArgs e) {        if(!IsPostBack)            {fillnation ();        Fillloadinfo (); }    }    //returns the page that displays the information    protected voidButton1_Click (Objectsender, EventArgs e) {Response.Redirect ("modify information. aspx"); }    //Modify update information    protected voidBtnok_click (Objectsender, EventArgs e) {        //identify the object you want to modify        stringCode =Txtcode.text; varquery = _context.info.where (P=>p.code = =code); if(Query. Count () >0) {Info data=query.            First (); //ModifyData. Name =txtName.Text; Data. Sex=Convert.toboolean (Txtsex.text); Data. Nation=Txtnation.text; Data. Birthday=Convert.todatetime (Txtbirthday.text); //Submit_context.submitchanges (); }    }}

Repeater binding Data:

Private New Mydbdatacontext ();      protected void Page_Load (object  sender, EventArgs e)    {        if (!  IsPostBack)        {            list<Info> list = _context.info.tolist ();             = list;            Repeater1.databind ();        }    }

To modify an information hyperlink:

1.a Tags:

<a href="edit.aspx?id=<% #Eval ("Code")%>"> Modify </a>

2.HyperLink button

 public  string   Showhref () { return   " edit.aspx?id=   + Eval ("  code   ); }  <asp:hyperlink Id= hyperlink1   runat="   Server   navigateurl="  <% #ShowHref ()%>   > Modify </asp:HyperLink> </t D> 

Webform---Modify personnel information

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.