I have a page with a label control at top. On Page Load I am setting the lable text to User.Identity.Name. This user name is also stored in my tblUserTable in the UserName Column.. To simplify things, I have a formview with only an item template. In my SELECT command, if I eliminate the WHERE clause, the first record is displayed. If I put in the WHERE clause as shown below, the data is not displayed. Any thoughts?
Code:
<%@PageLanguage="VB"MasterPageFile="~/bridgewho.master"Title="My Profile" %>
<scriptrunat="server">
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs)
lblUserName.Text = "User Name: " & User.Identity.Name
EndSub
</script>
<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"runat="Server">
<asp:LabelID="lblUserName"runat="server"Text="Label"></asp:Label>
<asp:FormViewID="FormView1"runat="server"DataSourceID="SqlDataSource1"DataKeyNames="UserID">
<ItemTemplate>
UserID:
<asp:LabelID="UserIDLabel"runat="server"Text='<%# Eval("UserID") %>'/>
<br/>
UserName:
<asp:LabelID="UserNameLabel"runat="server"Text='<%# Bind("UserName") %>'/>
<br/>
DisplayName:
<asp:LabelID="DisplayNameLabel"runat="server"Text='<%# Bind("DisplayName") %>'/>
<br/>
FirstName:
<asp:LabelID="FirstNameLabel"runat="server"Text='<%# Bind("FirstName") %>'/>
<br/>
Lastname:
<asp:LabelID="LastnameLabel"runat="server"Text='<%# Bind("Lastname") %>'/>
<br/>
Zip:
<asp:LabelID="ZipLabel"runat="server"Text='<%# Bind("Zip") %>'/>
<br/>
City:
<asp:LabelID="CityLabel"runat="server"Text='<%# Bind("City") %>'/>
<br/>
State:
<asp:LabelID="StateLabel"runat="server"Text='<%# Bind("State") %>'/>
<br/>
PhoneCell:
<asp:LabelID="PhoneCellLabel"runat="server"Text='<%# Bind("PhoneCell") %>'/>
<br/>
PhoneHome:
<asp:LabelID="PhoneHomeLabel"runat="server"Text='<%# Bind("PhoneHome") %>'/>
<br/>
Email:
<asp:LabelID="EmailLabel"runat="server"Text='<%# Bind("Email") %>'/>
<br/>
Pro:
<asp:CheckBoxID="ProCheckBox"runat="server"Checked='<%# Bind("Pro") %>'Enabled="false"/>
<br/>
GeneralApproach:
<asp:LabelID="GeneralApproachLabel"runat="server"Text='<%# Bind("GeneralApproach") %>'/>
<br/>
Rank:
<asp:LabelID="RankLabel"runat="server"Text='<%# Bind("Rank") %>'/>
<br/>
General:
<asp:LabelID="GeneralLabel"runat="server"Text='<%# Bind("General") %>'/>
<br/>
<asp:LinkButtonID="EditButton"runat="server"CausesValidation="True"CommandName="Edit"
Text="Edit User"/>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:steve48ConnectionString %>"
SelectCommand="SELECT * FROM [tblUser] WHERE ([UserName] = @UserName)">
<SelectParameters>
<asp:ControlParameterControlID="lblUserName"Name="UserName"PropertyName="Text"Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>