My Situation:
I’ ve a ListView, that get Data from the Active Directory. The User input a String (Lastname or a part of this) in a TextBox. Than the ListView list all AD Users with the same string from the TextBox. Every Line get a Button “Anzeigen” to get more Informations about the User. A second WebForm “Benutzer.aspx” display the Information about this User. I think I need a Value (ID or eMail) of the selected User for the second WebForm. So I need a Session. So if I click the Button “Anzeigen” I need the Value of the eMail or ect. of this actually Line in the ListView.
My Problem:
I don’t know how I can get the other Informations of this ListView Line. I think I need a kind of Index or I must control a Cell.
My Code:
ASPX
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="UserTable" runat="server" border="0" cellspacing="10" cellpadding="5">
<tr id="Tr1" runat="server">
<th id="Th1" runat="server">Benutzer</th>
<th id="Th2" runat="server">eMail</th>
<th id="Th3" runat="server">Vorname</th>
<th id="Th4" runat="server">Nachname</th>
<th id="Th5" runat="server">Telefon</th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td align="left" ><asp:Label ID="Label1" Text='<%# Eval("Benutzer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label5" Text='<%# Eval("Telefon") %>' runat="server" /></td>
<td align="left"><asp:Button ID="Button1" Text="Anzeigen" OnCommand="Button1_Command" CommandName="Anzeigen" CommandArgument="myArgument" runat="server" /></td>
</tr>
</ItemTemplate>
</asp:ListView>
CS
protected void Button1_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Anzeigen")
{
//Here I need a Session and the Informations about the Selected User in the Line
Response.Redirect("Benutzer.aspx");
}
}
tarasov
If I unerstand correctly, you need a reference to Label which shows the email in the list view. For this first get a reference, see the below code: