tags:

views:

13

answers:

1

Hi,

I have an asp.net datalist like this:

<asp:DataList ID="DataList_Trips" OnItemCommand="DataList_Trips_ItemCommand" >
<ItemTemplate>
<div class="divListTrips">
</div>
</ItemTemplate>
</asp:DataList>

Is there any chance when I click on the div with the class divListTrips, it will fire the event OnItemCommand?

Thanks in advance. Your help is much appreciated!

A: 

I would suggest using jQuery to call a page method, like in this example: http://www.seoasp.net/post/2008/07/16/jQuery-To-Call-ASPNET-Page-Methods-and-Web-Services.aspx

instead of trying to coerce it to call your ItemCommand handler.

dave thieben
Page method is always static. That is not a good option in my project. Thanks anyway. I think I should wrap all the text of the div inside a linkButton, that would be also a good idea!
JoesyXHN
that might *work*, but putting a DIV inside a A tag is not compliant. If Page methods aren't a good option, you could achieve a similar behavior by passing a "action" querystring argument to your page. In the OnLoad method, check the action argument and perform the desired behavior. If there is not action argument, do the normal page load behavior.
dave thieben