How to add data to a data table using the createuserwizard control of Asp.net 2.0

Source: Internet
Author: User

In our application system, data in user tables of Asp.net 2.0 often cannot meet our needs, and more data needs to be added. One possible solution is to use profile, the more common solution is to add data to our own table in createuserwizard.

The primary key in the table designed by the user management system in combination with Asp.net 2.0 to save additional user information is the foreign key of the User table ID. You can obtain the ID from the membershipuser attribute provideruserkey. use the createuserwizard oncreateduser event. in this event, you can use the getuser method of the membership class to obtain the currently created user membershipuser.

Membershipuser user = membership. getuser = (mycreateuserwizar. username );

You can use the username attribute of createuserwizard to obtain the registered username. When you create a user membershipuser object, you can use provideruserkey to obtain the user's primary key value (a guid value ):

In the oncreateduser event of createuserwinard, you can obtain the additional user information you want to add and insert the value of provideruserkey into your own database table. The following is an example of how to use it:

Protected void createuserwizard1_createduser (Object sender, system. eventargs E)
{

Membershipuser user = membership. getuser (createuserwizard1.username );

If (user! = NULL)
Throw new applicationexception ("user not found .");

Guid userid = (guid) user. provideruserkey;

// Obtain the additional user registration information in the createuserwizard Control

Textbox mydata = createuserwizard1.createuserstep. contenttemplatecontainer. findcontrol ("textbox1") as textbox;

Userinfo = new userinfo ();

Userinfo. ID = userid;

Userinfo. QQ = mydata. text;

......

This. addmydatatomydatasource (userinfo );
}

Private void addmydatatomydatasource (userinfo mydata)
{
// Add data to your database table
}

Membership in GardenArticle:

ASP. NET 2.0 membership

Asp.net 2.0 user management function structure

Membership settings

In ASP. NET 2.0, how does one use membership?

Membership Learning (4)-custom membershipprovider [xgluxv]

Membership Learning (3) Introduction to membership providers [xgluxv] membership Learning (2) Introduction to membership [xgluxv] membership Learning (1) Introduction to membership [xgluxv]

Membership: It's not easy to love you.

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.