Note that there are some explanatory texts on larger screens.

plurals
  1. POLinkButton Won't Trigger Command Event
    primarykey
    data
    text
    <p>I know there are a lot of related posts or articles about this, but then it seems that they're not helping my case. I've even compared with a working sample at this site, <a href="http://www.ezineasp.net/post/ASP-Net-LinkButton-Command-Event.aspx" rel="nofollow">http://www.ezineasp.net/post/ASP-Net-LinkButton-Command-Event.aspx</a>, I don't think there's much difference. I thought my code should be working but apparently it just won't. I'm so sorry if this looks like a duplicate, but it's my last resort to post here.</p> <p>Here's my HTML:</p> <pre><code> &lt;asp:ListView runat="server" ID="AppsList"&gt; &lt;LayoutTemplate&gt; &lt;div&gt; &lt;asp:PlaceHolder runat="server" ID="itemPlaceHolder" /&gt; &lt;/div&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;div class="applist"&gt; &lt;div class="app"&gt; &lt;asp:ImageButton ID="imgbtnApp" runat="server" ImageUrl='&lt;%#Eval("Icon") %&gt;' height="100" width="100" CommandName="Select" CommandArgument='&lt;%# Eval("ID") %&gt;' OnCommand="AppsList_ItemCommand" /&gt; &lt;/div&gt; &lt;div class="appname"&gt; &lt;asp:LinkButton ID="linkbtnAppName" runat="server" CommandName="Select" ForeColor="#333333" CommandArgument='&lt;%# Eval("ID") %&gt;' OnCommand="AppsList_ItemCommand" CssClass="linkbtnAppName"&gt;&lt;%# Eval("AppName") %&gt;&lt;/asp:LinkButton&gt; &lt;/div&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;EmptyDataTemplate&gt; Sorry - Nothing found. &lt;/EmptyDataTemplate&gt; &lt;/asp:ListView&gt; </code></pre> <p>Code:</p> <pre><code>protected void AppsList_ItemCommand(object sender, CommandEventArgs e) { if (e.CommandName == "Select") { txtTest.Text = e.CommandArgument.ToString(); } } </code></pre> <p>What I'm trying to achieve here is to capture the ID of the item in the ListView into the textbox when I click on either the Image Button or Link Button. Both will perform the same thing. I already got the Image button to work. When I click the Image, the ID, e.g 1 will appear in the textbox. But when I want to do the same thing with the Link Button, nothing will happen. The event is not being triggered in any way. </p> <p>I've seen some posts talking about repeaters or AJAX to do the same thing, but I was just wondering why can't this code work. I would appreciate any pointer.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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