Sunday, September 5, 2010

Fire ItemCommand event of repeater from <div> click or <tr> click using javascript


<asp:Repeater ID="rpt" runat="server" OnItemCommand="rpt_ItemCommand" OnItemCreated="rpt_ItemCreated">
<table width="100%" cellpadding="0" cellspacing="0">
<tr onclick='javascript:FireItemCommand(<%#DataBinder.Eval(Container, "ItemIndex", "")%>)'
style="cursor: pointer">
<%# Eval("Name") %>
<asp:LinkButton ID="lnkDim" runat="server" Text="lnk123" CommandArgument='<%# Eval("Name") %>'></asp:LinkButton>

function FireItemCommand(index) {

__doPostBack('rpt$ctl0' + parseInt(index + 1).toString() + '$lnkDim', '');


1 comment:

Don Gibson said...

Thanks!!!! Saved me a ton of time working this one out! Works great.