简体   繁体   中英

asp.net listview how to fire itemcommand event on a <tr>?

and thanks for reading my post.

I think.. this might be pretty easy for a experienced asp.net developer which have tweaked much with listviews and such.

The thing is.. I have this LinkButton which ofcourse.. have the commandname and commandargument and that works like a charm!

The issue is.. that the customer wants the WHOLE row to be clickable.. not just the linkbutton in the first .

So.. therefore.. i'm trying to force a itemcommand on a table row (tr)

here is the code :

<asp:ListView runat="server" ID="lvProdukter" DataKeyNames="ProduktSXX" OnItemCommand="lvProdukter_ItemCommand" ItemType="ProductXXXX">

<ItemTemplate>

<tr>

<td>

<asp:LinkButton runat="server" ID="lnkSelectProdukt" CssClass="lvitemlink" CommandArgument='<%# Item.ProduktS + ";" + Item.VaregrId %>'
CommandName="SelectProdukt">
<%# Item.TheName ?? "&nbsp;" %>
</asp:LinkButton>

</td>

<td>

bla-bla-bla..

</td>

etc.etc....

Well I haven't tried it but I think there are two ways of doing this.

  1. Make the tr runat='server' and on click use _dopostback function. and see it works or not.

  2. Use jQuery tr click and call link button click inside it.

    $("#lvProdukter tr").click(function() { //call the link button click here. });

use Jquery on the client side:

$('#table-name').on('click', 'tr', function()
{
    alert('Hello');

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM