Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
.ascx file:

XML
<asp:Repeater ID="rptrCategory" DataSourceID="dsCollections" runat="server" >
   <ItemTemplate>
           <asp:HiddenField ID="hfId" value='<%# Eval("Id") %>' runat="server" />
    <li id="l1" runat="server"  class='<%#Eval("CategName") %>'><span class="folder"><%# Eval("CategName") %></span>
     <ul >
   <asp:Repeater id="rptrTypes" DataSourceID="dsTypes" runat="server" OnItemCommand="rptrCategory_ItemCommand">
 <ItemTemplate>
     <li id="current">

         <asp:LinkButton ID="LinkButton1" runat="server" style="color:#000; text-decoration:none;"
CommandName="Lnkks" CommandArgument='<%#Eval("CategName") +";"+ Eval("SubCategName")%>' ><%# Eval("SubCategName")%></asp:LinkButton>

   </span>
     </li>
     </ItemTemplate>
      </asp:Repeater>
      </ul>
      </li>
      <asp:SqlDataSource ID="dsTypes" runat="server" ConnectionString="<%$ ConnectionStrings:csConnectionString %>"
       SelectCommand="SELECT SubCategory.SubCategName,Category.CategName, SubCategory.Id, SubCategory.CategId FROM Category INNER JOIN SubCategory ON Category.Id = SubCategory.CategId where Category.Id= @categ">
       <SelectParameters>
       <asp:ControlParameter Name="categ" ControlID="hfId" PropertyName="Value" />
        </SelectParameters>
       </asp:SqlDataSource>
       </ItemTemplate>
       </asp:Repeater>
       <asp:SqlDataSource ID="dsCollections" runat="server" ConnectionString="<%$ ConnectionStrings:csConnectionString %>"
        SelectCommand="SELECT [CategName], [Id] FROM [Category]"></asp:SqlDataSource>


Code:

C#
protected void rptrCategory_ItemCommand(object source, RepeaterCommandEventArgs e)
  {
      if (e.CommandName == "Lnkks")
      {
          Response.Write("work");
      }
  }
Posted
Comments
Dilan Shaminda 2-Jan-15 0:32am    
Do you get any exception? Debug your code and check what you are getting as command argument value?
Member 11319592 2-Jan-15 0:40am    
break point was not come to the item command event.
Dilan Shaminda 2-Jan-15 1:07am    
CommandArgument parameters are fine.Did it work for one parameter?
Member 11319592 2-Jan-15 2:46am    
one parameter value was not working,
Dilan Shaminda 2-Jan-15 2:51am    
i answered your question in this thread
http://www.codeproject.com/Answers/858647/repeater-control-link-button-not-working#answer3

so it should be work for one paramerter value..In this question also you are passing commandArgument correctly.I think the problem is you have nested repeaters.Try google Hope you will find the answer :-)

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