我試圖做按鈕命令不工作
<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>
<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>
<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事件中是行不通的。我已經在那裏應用了中斷點,但是光標不會到達中斷點。
檢查它是否調試到'oncommand =「Button3_Command」'? –
在設計視圖中,當您雙擊button3時,它會將您帶到事件處理函數嗎? (Button3_Click)。如果不是,那麼自動生成的代碼文件可能會有一些問題。刪除它。並再次調試。文件將生成,並希望問題將得到解決 – Romaan
我已經這樣做,但Button3_click事件不起作用。 –