Get value of selected item in DataList
<p>I'm trying to get the value from the selected item when I click a button.</p>

<p>Here is my code:</p>

<pre><code>&lt;asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" Width="100%"&gt;
    &lt;ItemTemplate&gt;
        &lt;p class="own"&gt;&lt;asp:Image ID="Image1" runat="server" ImageUrl='&lt;%# "GetImageDatafromDB.aspx?id=" + System.Convert.ToString(Eval("ID")) %&gt;' Width="230" Height="250"/&gt;
            &lt;br /&gt;
            &lt;span class="own1" style="width:230px;"&gt;&lt;br /&gt;&lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Eval("Name") %&gt;' Font-Bold="True" Font-Size="1.2em" ForeColor="White"/&gt;
            &lt;br /&gt;
            &lt;asp:Label ID="Label5" runat="server" Text="Direktor :" style="color:#06D85F; float:left"&gt;&lt;/asp:Label&gt;&lt;asp:Label ID="Label2" runat="server" CssClass="InFo" Text='&lt;%# Eval("fattare") %&gt;' Font-Italic="true"/&gt; 
            &lt;br /&gt;
            &lt;asp:Label ID="Label4" runat="server" Text="Year : " style="color:#06D85F; float:left;"&gt;&lt;/asp:Label&gt;&lt;asp:Label ID="Label3" CssClass="InFo" runat="server" Text=' &lt;%# (Eval("Ar")) %&gt;' /&gt;
            &lt;/br&gt;
            &lt;asp:Button ID="Button1"  runat="server" Text="Visa" CommandName="ButtonClick"/&gt;
            &lt;/span&gt;
            &lt;asp:Label ID="Label6" runat="server" Visible="false" Text='&lt;%# Eval("Name") %&gt;'&gt;&lt;/asp:Label&gt;
        &lt;/p&gt;
    &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
</code></pre>



<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["Hemsida"].ConnectionString;
        DataTable dt = new DataTable();
        SqlConnection conn = new SqlConnection(connectionString);
        using (conn)
        {
            SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Movies", conn);
            ad.Fill(dt);
        }
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }
}

protected void Button1_Click(object sender, EventArgs e)
{
    foreach (DataListItem item in DataList1.Items)
    {
        Label myTempLabel = (Label)item.FindControl("Label6");

        myTempLabel.Visible = true;
    }
}
</code></pre>

<p>When I click the button, I get all of the names of all of the items, but I only want to get the name of the selected item.</p>