468,161 Members | 2,090 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

DropDownList, CreateUserWizard - postback issues

Hi Everyone,

I have a CreateUserWizard my public sign up page of my website. I
have edited the wizard to include collection of other personal
information. I have a DropDownList for the selection of the
Graduation year. Find the code below to Insert all the additional
information to another database when a new ASP user is created. The
DropDownList gets cleared of all data during execution of this code.
Your thoughts on the solution expected.

DropDownList Properties:

* EnableViewState: True
* AppendDataBoundItems: False
* AutoPostBack: False
* Causes Validation: False

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Page.IsPostBack = False Then

Dim YearList As DropDownList =
CreateUserWizardStep1.ContentTemplateContainer.Fin dControl("Year")
Dim nStartYear As Integer = 1980
Dim nCurrentYear As Integer = CType(Date.Now.Year,
Integer)

For index As Integer = nStartYear To nCurrentYear
YearList.Items.Add(index)
Next

End If
End Sub
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object,
ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser

Dim UserNameEntered As TextBox =
CreateUserWizardStep1.ContentTemplateContainer.Fin dControl("Username")
Dim DateOfBirth As TextBox =
CreateUserWizardStep1.ContentTemplateContainer.Fin dControl("DateOfBirth")
Dim YearList As DropDownList =
CreateUserWizardStep1.ContentTemplateContainer.Fin dControl("Year")

Dim User1 As MembershipUser =
Membership.GetUser(UserNameEntered.Text)
Dim UserGUID As Object = User1.ProviderUserKey
Dim DOB As Date = Date.ParseExact(DateOfBirth.Text, "dd/MM/
yyyy", Nothing)

'The Problem is seen in the line below, the DropDownList (YearList)
gets cleared of all
'Items which makes me unable to find the Selected Value of the Year
of Graduation

Dim GraduatedYear As Date =
Date.ParseExact(YearList.SelectedValue, "yyyy", Nothing)

Dim DataSource As SqlDataSource =
CreateUserWizardStep1.ContentTemplateContainer.Fin dControl("InsertUserInfo")
DataSource.InsertParameters.Add("ASPUserId",
UserGUID.ToString())
DataSource.InsertParameters.Add("GraduationYear",
GraduationYear)
DataSource.Insert()

Roles.AddUserToRole(UserNameEntered.Text, "MemberUser")

End Sub

Sep 10 '07 #1
0 1981

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by gcdp | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.