Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a repeater in which I have taken a table (Which was for better UI) in that table I have a link button... I want to write some code that should be executed when user click on add button..
I wrote that code in ItemCommand event of repeater but controll is not going inside that event..

code is as follow

asp code:
ASP.NET
<asp:Repeater ID="rpt1" runat="server" OnItemCommand="rpt1_ItemCommand">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                                                            <tr>
                                                                                                                                <td width="13%" align="left" valign="top">
                                                                                                                                                                                                                                                                        <a id="StarRating" class='<%# GetStarRating(Eval("Rating")) %>'  runat="server"></a>
                                                                                                                                </td>
                                                                                                                                <td width="17%" align="left" valign="top">
                                                                                                                                    <div class="radius-btn">
                                                                                                                                        <a href="#" class='<%# Getclass(Eval("MyvuReco")) %>'>
                                                                                                                                            <%# Eval("MyvuReco") %></a></div>
                                                                                                                                </td>
                                                                                                                                <td width="58%" align="left" valign="top" class="nav-grey">
                                                                                                                                    NAV : <span>
                                                                                                                                        <%# Eval("navrs") %></span> as recorded on
                                                                                                                                    <%# Eval("navdate") %>
                                                                                                                                </td>
                                                                                                                                                                                                                                                                <td width="30%" align="right" class="remove">
                                                                                                                                    <asp:LinkButton runat="server" ID="lnkBasket" CommandName="add" class="add-basket"
                                                                                                                                        >Add</asp:LinkButton>
                                                                                                                                </td>
                                                                                                                            </tr>
                                                                                                                        </table>


and Codebehind

VB
Protected Sub rpt1_ItemCommand2(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rpt1.ItemCommand
my code
End Sub


any reason why control is not going in that event while debugging
Posted

you define property of Reapeater OnItemCommand="rpt1_ItemCommand"


C#
Protected Sub rpt1_ItemCommand2(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rpt1.ItemCommand
my code
End Sub


you should pass rpt1_ItemCommand2 in repeater itemcommand
 
Share this answer
 
Comments
[no name] 23-Oct-13 3:00am    
Thanks for answering..
I have corrected it but still same problem... :(
uspatel 23-Oct-13 3:10am    
place your table content inside <itemtemaplate>
and also check if you have validationn on page or set CauseValidation=false for linkbutton
[no name] 23-Oct-13 3:40am    
You might get surprised but I am stuck with strange behavior.... sometime its going inside event sometime not... however breakpoint is at same location..
[no name] 23-Oct-13 5:08am    
Big thanks fella !!!
See this : How to make a linkbutton onclick with parameters[^]

Convert to VB.NET if required.

Regards..
 
Share this answer
 
Comments
[no name] 23-Oct-13 2:54am    
I have the same code except CommandArgument for link button... but it is optional as written in ur link...
please correct me if I have mistaken
Thanks
Thanks7872 23-Oct-13 2:59am    
Who says you have same code? Copy paste the code in that link and see what happens.
[no name] 23-Oct-13 3:07am    
Sorry, I am not getting u exactly...
I pasted same link... it says... BC30451: Name 'Post' is not declared.
Thanks7872 23-Oct-13 3:12am    
I think you should have a good book first. Why you think that copy pasting others code without changing even a single word work for you? The idea is try to understand how it works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900