Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access the label control of list view?
    primarykey
    data
    text
    <p>I want to access one of the labels inside the <code>DataList</code> control. How can I access that in my code behind file (C#)? I'm using Visual Studio 2010</p> <p>I want to access text property of "productnamelabel"</p> <p>My code is:</p> <pre><code>&lt;asp:DataList ID="DataList1" runat="server" DataKeyField="id" DataSourceID="SqlDataSource1"&gt; &lt;ItemTemplate&gt; productName: &lt;asp:LinkButton ID="LinkButton1" runat="server" Text='&lt;%# Eval("productName") %&gt;'&gt;&lt;/asp:LinkButton&gt; &lt;asp:Label ID="productNameLabel" runat="server" Text='&lt;%# Eval("productName") %&gt;' /&gt; &lt;br /&gt; brand: &lt;asp:Label ID="brandLabel" runat="server" Text='&lt;%# Eval("brand") %&gt;' /&gt; &lt;br /&gt; &lt;asp:Image ID="Image1" runat="server" ImageUrl='&lt;%# Eval("image") %&gt;' /&gt; &lt;br /&gt; catagory: &lt;asp:Label ID="catagoryLabel" runat="server" Text='&lt;%# Eval("catagory") %&gt;' /&gt; &lt;br /&gt; price: &lt;asp:Label ID="priceLabel" runat="server" Text='&lt;%# Eval("price") %&gt;' /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:shopingConnectionString1 %&gt;" SelectCommand="SELECT [id], [productName], [brand], [image], [catagory], [price] FROM [product] WHERE ([productName] = @productName)"&gt; &lt;SelectParameters&gt; &lt;asp:QueryStringParameter Name="productName" QueryStringField="pName" Type="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload