Greetings - I'm wondering if anyone can assist me with troubleshooting. When I login, my page displays the heading, but not the user record (formview).
I am using the default membership and users tables (SQL server 2005) along with the basic login control. I have a table called 'members' where I added a column for the UserID. I copied the user ID from the Users table for my test user.
Below is my ASP and VB code. Thanks in advance for your troubleshooting assistance!
<asp:LoginView ID="LoginViewMemberDetails" runat="server">
<LoggedInTemplate>
<br /><br /><br />
<div class="heading">Account Information</div>
<br />
<asp:SqlDataSource ID="editmember" runat="server"
ConnectionString="<%$ ConnectionStrings:abc %>"
SelectCommand="SELECT * FROM Members WHERE UserID=@UserID"
UpdateCommand="Update Members SET FirstName=@FirstName, LastName=@LastName, Address=@Address, City=@City, State=@State, ZipCode=@ZipCode, PhoneNumber=@PhoneNumber, EmailAddress=@EmailAddress, SendMailType=@SendMailType, SendEmailType=@SendEmailType, CoName=@CoName, JobTitle=@JobTitle, CoAddress=@CoAddress, CoCity=@CoCity, CoState=@CoState, CoZipCode=@CoZipCode, CoPhoneNumber=@CoPhoneNumber, CoEmailAddress=@CoEmailAddress, EducationLevel=@EducationLevel, Degrees=@Degrees, WorkedInTechnology=@WorkedInTechnology, ShareInformation=@ShareInformation WHERE UserID=@UserID">
<selectParameters><asp:QueryStringParameter Name="UserId" QueryStringField="UserName" /></SelectParameters>
</asp:SqlDataSource>
<br /><br />
<asp:FormView ID="FormViewEditInfo" runat="server" DataSourceID="editmember" DataKeyNames="UserID" AllowPaging="false">
<ItemTemplate>
<asp:LinkButton ID="EditLink" runat="server" Text="- Edit your Information -" CommandName="Edit" />
</ItemTemplate>
<EditItemTemplate>
<div>
<b>First Name:</b> <asp:TextBox id="TextBox1" Width="200" runat="server" text='<%# Bind("firstname") %>' /><br />
<b>Last Name:</b> <asp:TextBox id="TextBox2" Width="200" runat="server" text='<%# Bind("lastname") %>' /><br />
<b>Street Address (home):</b> <asp:TextBox id="TextBox3" Width="500" runat="server" text='<%# Bind("address") %>' /><br />
<b>City:</b> <asp:TextBox id="TextBox4" Width="200" runat="server" text='<%# Bind("city") %>' /><br />
<b>State:</b> <asp:TextBox id="TextBox5" Width="200" runat="server" text='<%# Bind("state") %>' /><br />
<b>Zip Code:</b> <asp:TextBox id="TextBox6" Width="200" runat="server" text='<%# Bind("zipcode") %>' /><br />
<b>Home Phone:</b> <asp:TextBox id="TextBox7" Width="300" runat="server" text='<%# Bind("phonenumber") %>' /><br />
<b>Email Address (home):</b> <asp:TextBox id="TextBox8" Width="400" runat="server" text='<%# Bind("emailaddress") %>' /><br />
<b>Company Name:</b> <asp:TextBox id="TextBox9" Width="400" runat="server" text='<%# Bind("coname") %>' /><br />
<b>Job Title:</b> <asp:TextBox id="TextBox10" Width="300" runat="server" text='<%# Bind("jobtitle") %>' /><br />
<b>Work Address:</b> <asp:TextBox id="TextBox11" Width="500" runat="server" text='<%# Bind("coaddress") %>' /><br />
<b>City:</b> <asp:TextBox id="TextBox12" Width="200" runat="server" text='<%# Bind("cocity") %>' /><br />
<b>State:</b> <asp:TextBox id="TextBox13" Width="200" runat="server" text='<%# Bind("costate") %>' /><br />
<b>Zip Code:</b> <asp:TextBox id="TextBox14" Width="200" runat="server" text='<%# Bind("cozipcode") %>' /><br />
<b>Work Phone:</b> <asp:TextBox id="TextBox15" Width="300" runat="server" text='<%# Bind("cophonenumber") %>' /><br />
<b>Work Email:</b> <asp:TextBox id="TextBox16" Width="400" runat="server" text='<%# Bind("coemailaddress") %>' /><br />
<b>Highest Education Level Completed:</b> <asp:TextBox id="TextBox17" Width="200" runat="server" text='<%# Bind("educationlevel") %>' /><br />
<b>Undergraduate Degree:</b> <asp:TextBox id="TextBox18" Width="400" runat="server" text='<%# Bind("degrees") %>' /><br />
<b>Years Worked in Technology:</b> <asp:TextBox id="TextBox19" Width="400" runat="server" text='<%# Bind("workedintechnology") %>' /><br />
<b>Send snail mail to:</b> <asp:TextBox id="TextBox20" Width="400" runat="server" text='<%# Bind("sendmailtype") %>' /><br />
<b>Send email to:</b> <asp:TextBox id="TextBox21" Width="400" runat="server" text='<%# Bind("sendemailtype") %>' /><br />
<b>Is it ok to share your contact information with ATW members (true=yes; false=no):</b> <asp:TextBox id="TextBox22" Width="400" runat="server" text='<%# Bind("shareinformation") %>' /><br />
<asp:LinkButton ID="SaveLink" Text="- Save -" runat="server" CommandName="Update" />
<asp:LinkButton ID="CancelLink" Text="- Cancel -" runat="server" CommandName="Cancel" />
</div>
</EditItemTemplate>
</asp:FormView>
</LoggedInTemplate>
</asp:LoginView>
Imports System.Web.Configuration
Imports System.Data
Imports System.Data.SqlClient
Partial Class Secure_SecureMemberInfo
Inherits System.Web.UI.Page
Dim TextBox1 As TextBox
Dim TextBox2 As TextBox
Dim TextBox3 As TextBox
Dim TextBox4 As TextBox
Dim TextBox5 As TextBox
Dim TextBox6 As TextBox
Dim TextBox7 As TextBox
Dim TextBox8 As TextBox
Dim TextBox9 As TextBox
Dim TextBox10 As TextBox
Dim TextBox11 As TextBox
Dim TextBox12 As TextBox
Dim TextBox13 As TextBox
Dim TextBox14 As TextBox
Dim TextBox15 As TextBox
Dim TextBox16 As TextBox
Dim TextBox17 As TextBox
Dim TextBox18 As TextBox
Dim TextBox19 As TextBox
Dim TextBox20 As TextBox
Dim TextBox21 As TextBox
Dim TextBox22 As TextBox
Dim TextBox23 As TextBox
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
getData(Me.User.Identity.Name)
End If
End Sub
Private Sub getData(ByVal user As String)
Dim dt As New DataTable()
Dim connection As New SqlConnection("abc")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT * from Members WHERE UserID = @UserID", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.AddWithValue("@UserID", user)
sqlDa.Fill(dt)
If dt.Rows.Count > 0 Then
TextBox1.Text = dt.Rows(0)("firstname").ToString()
TextBox2.Text = dt.Rows(0)("lastname").ToString()
TextBox3.Text = dt.Rows(0)("address").ToString()
TextBox4.Text = dt.Rows(0)("city").ToString()
TextBox5.Text = dt.Rows(0)("state").ToString()
TextBox6.Text = dt.Rows(0)("zipcode").ToString()
TextBox7.Text = dt.Rows(0)("phonenumber").ToString()
TextBox8.Text = dt.Rows(0)("emailaddress").ToString()
TextBox9.Text = dt.Rows(0)("sendmailtype").ToString()
TextBox10.Text = dt.Rows(0)("sendemailtype").ToString()
TextBox11.Text = dt.Rows(0)("coname").ToString()
TextBox12.Text = dt.Rows(0)("jobtitle").ToString()
TextBox13.Text = dt.Rows(0)("coaddress").ToString()
TextBox14.Text = dt.Rows(0)("cocity").ToString()
TextBox15.Text = dt.Rows(0)("costate").ToString()
TextBox16.Text = dt.Rows(0)("cozipcode").ToString()
TextBox17.Text = dt.Rows(0)("cophonenumber").ToString()
TextBox18.Text = dt.Rows(0)("coemailaddress").ToString()
TextBox19.Text = dt.Rows(0)("educationlevel").ToString()
TextBox20.Text = dt.Rows(0)("degrees").ToString()
TextBox21.Text = dt.Rows(0)("workedintechnology").ToString()
TextBox22.Text = dt.Rows(0)("shareinformation").ToString()
End If
connection.Close()
End Sub
End Class