Hello,
sorry - another newbie. I found a lot of similar FQAs and Solutions, but they do not fit ...
For some reasons I do not use Visual Studio and not Razor. My code example is a single .aspx page (with no code behind). I would like to get the value (=real email address) from a database into a session. Most likely I Need to insert some code into the onload section ...
The Access to the database works and I receive the ID and email in the DataList. But how to get it from the DataList to my email or into a session?
Thanks for Help
[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ language="VB" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%
Session("pidx")="kk50"
%>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQLServer %>" SelectCommand="SELECT [pidcontact], [email] FROM [wwwcontact] WHERE ([pidcontact] = @pidcontact)">
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="pidcontact" SessionField="pid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DataList id="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
pidcontact: <asp:Label id="pidcontactLabel" runat="server" Text='<%# Eval("pidcontact") %>' /><br />
email: <asp:Label id="emailLabel" runat="server" Text='<%# Eval("email") %>' />
<% ' Session("email") = ??? I need to get the Eval("email") value in this session %>
<%# Session("email") = DataBinder.Eval(Container.DataItem, "email") %>
</ItemTemplate>
</asp:DataList>
Pidx Session: <% response.write (Session("pidx")) %><br />
email Session: <% response.write (Session("email")) %><br />
</form>
</body>
</html>
]
------------------ RESULT:
pidcontact: 1
email: Smith@email.com False
Pidx Session: kk50
email Session: