.ascx文件转发器链接按钮不起作用 [英] .ascx file repeater link button not working

查看:69
本文介绍了.ascx文件转发器链接按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.ascx文件:



.ascx file:

<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:

protected void rptrCategory_ItemCommand(object source, RepeaterCommandEventArgs e)
  {
      if (e.CommandName == "Lnkks")
      {
          Response.Write("work");
      }
  }

推荐答案

ConnectionStrings:csConnectionString %>

SelectCommand = SELECT SubCategory.SubCategName,Category.CategName,SubCategory.Id,SubCategory.CategId FROM类别INNER JOIN子类别ON Category.Id = SubCategory.CategId其中Category.Id = @categ >
< SelectParameters >
< asp:ControlParameter 名称 = categ ControlID = hfId PropertyName = / >
< / SelectParameters >
< / asp:SqlDataSource >
< / ItemTemplate >
< / asp:Repeater >
< asp:SqlDataSource ID = dsCollections 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 %>

< span class =code-attribute> SelectCommand = SELECT [CategName] ,[Id] FROM [Category] > < / asp:SqlDataSource >
ConnectionStrings:csConnectionString %>" SelectCommand="SELECT [CategName], [Id] FROM [Category]"></asp:SqlDataSource>





代码:





Code:

protected void rptrCategory_ItemCommand(object source, RepeaterCommandEventArgs e)
  {
      if (e.CommandName == "Lnkks")
      {
          Response.Write("work");
      }
  }


这篇关于.ascx文件转发器链接按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆