0

我正在尝试做

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <asp:DataList ID="DataList2" runat="server" CellPadding="4" ForeColor="#333333" OnItemCommand="DataList2_ItemCommand">
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <AlternatingItemStyle BackColor="White" />
            <ItemStyle BackColor="#E3EAEB" />
            <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <ItemTemplate>
                <asp:Label ID="Label6" runat="server" Text='<%# Eval("Discription") %>'></asp:Label>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label7" runat="server" Text='<%# Eval("SubmittedTime") %>'></asp:Label>
                <br />
                <br />
                <asp:Label ID="Label9" runat="server" ForeColor="#CC0000" Text="Comments"></asp:Label>
                <br />
                <br />
                <asp:LinkButton ID="LinkButton5" runat="server" OnClick="LinkButton5_Click">Add Comment</asp:LinkButton>
                <br />
                <asp:Panel ID="Panel2" runat="server" Visible="False" Style="padding-left: 100px;">
                    <asp:TextBox ID="TextBox2" runat="server" Height="40px" TextMode="MultiLine" Width="497px"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Add" CommandName="Add"
                        OnCommand="Button3_Command" />
                </asp:Panel>
                <br />
            </ItemTemplate>
        </asp:DataList>
    </ContentTemplate>
</asp:UpdatePanel>

button3_Click 的编码是

 protected void Button3_Click(object sender, EventArgs e)
{Button pn = (Button);
    DataListItem dl = (DataListItem)pn.NamingContainer;
    Panel p1 = (Panel)dl.NamingContainer;
    TextBox pan = (TextBox)dl.FindControl("TextBox2");}

但是 button3_Click 事件不起作用。我已经在那里应用了断点,但光标没有出现在断点上。

4

2 回答 2

1

ControlID="Button1" to ControlID="Button3"

于 2012-11-07T09:07:32.630 回答
0

检查您是否能够DataList2_ItemCommand通过单击Button3按钮进入处理程序?如果是,那么您应该能够进入CommandName="Add"那里。

于 2012-11-07T09:12:11.563 回答