Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ASP.net中访问嵌套中继器内的按钮?_Asp.net_Button_Nested_Repeater - Fatal编程技术网

如何在ASP.net中访问嵌套中继器内的按钮?

如何在ASP.net中访问嵌套中继器内的按钮?,asp.net,button,nested,repeater,Asp.net,Button,Nested,Repeater,我一直试图了解正在发生的事情,但我在网上搜索却毫无结果 如何访问嵌套中继器内的按钮?我花了这么多时间研究/实验,我不明白发生了什么 HTML标记: <asp:Repeater runat="server" ID="repQuestionTopics"> .... <asp:Repeater ID="repQA" runat="server"> .... <strong>Was this article helpf

我一直试图了解正在发生的事情,但我在网上搜索却毫无结果

如何访问嵌套中继器内的按钮?我花了这么多时间研究/实验,我不明白发生了什么


HTML标记:

<asp:Repeater runat="server" ID="repQuestionTopics">
    ....
    <asp:Repeater ID="repQA" runat="server">
        ....
        <strong>Was this article helpful?</strong>&nbsp; 
        <button class="button tiny secondary radius" runat="server" 
              CommandName="voteYes" id="btnVoteHelpfulYes">Yes</button> 
        <button class="button tiny secondary radius" runat="server" 
              CommandName="voteNo" ID="btnVoteHelpfulNo">No</button>
    </asp:Repeater>
</asp:Repeater>
//Handles repQuestionTopics.ItemCommand
Public Sub repTopics_ItemCommand(Sender As Object, e As RepeaterCommandEventArgs)
    If e.CommandName = "voteYes" Then
        ....
    End If
End Sub
如何访问
repQA
?出于某种原因,我的代码隐藏不允许我编写函数Handles repQA.ItemCommand-为什么?我曾尝试使用类似(添加OnClick)的方法在asp端直接输入函数:

单击按钮
voteYes
时,我希望能够转到数据库并更新计数器,以便跟踪该问题答案的赞成票和反对票数量


无论我执行了什么更改,当我单击按钮时,页面都会刷新,仅此而已。

HTML标记:您必须将
OnItemCommand
事件添加到内部中继器
repAQ

<asp:Repeater ID="repQA" runat="server" OnItemCommand="repQA_ItemCommand">
ASP.Net:

<asp:Repeater ID="repQA" runat="server" OnItemCommand="repQA_ItemCommand">
Public Sub repQA_ItemCommand(Sender As Object, e As RepeaterCommandEventArgs)
    // check for right name of command
    If e.CommandName = "voteYes" Then
        ....
    End If
End Sub
protected void repQA_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    // check for right name of command
    if(e.CommandName == "voteYes")
    {
        ....
    }
}