Why drop down menu not showing ID from database? I have login page. when user enter their username and password, I will create a session from them.
Session["username"] = Login1.UserName;
I have two table in my database. 1 is aspnet_Users (keep all users info) and another one is CarReserve table (contains of ID, username and booking details which all is managed by admin)
In user page, when user click on MY BOOKING, it will have a drop down menu which only has ID (from CarReserve) then after user choose the ID from there, they get to view all the details from CarReserve that only belongs to ID. This is my code to retrieve the ID from database:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="ID" DataValueField="ID"
Height="21px" Width="147px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Connection %>"
SelectCommand="SELECT CarReserve.ID
FROM CarReserve
INNER JOIN aspnet_Users
ON CarReserve.UserName = aspnet_Users.UserName WHERE CarReserve.UserName = @UserName">
<SelectParameters>
<asp:SessionParameter Name="UserName"
SessionField="session["username"]" />
</SelectParameters>
</asp:SqlDataSource>
The problem is the drop down is not showing the ID of current login user. Can someone tell me what is wrong with my codes? Thanks
Your
SessionFieldparameter should read