从表中访问按钮

时间:2015-01-19 21:23:06

标签: c# asp.net user-controls

我正在尝试更改窗体中表格内按钮的可见性。但我无法找到控制权。

UserControl Page

<asp:FormView ID="FormView1" runat="server" DataSourceID="ds1" DefaultMode="Edit" OnItemCommand="FormView1_ItemCommand">
    <EditItemTemplate>
        <table id="t1">
            <tr>
                <td >
                     <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                </td>
             </tr>
        </table>
 </EditItemTemplate>
</asp:formview>

我想更改&#34; InsertButton&#34;的可见性为假。

Button btInsert = (Button)FormView1.FindControl("InsertButton");
        if (btInsert!=null)
        {
            btInsert.Visible = false;
        }

COuld任何人,解释我如何才能找到按钮控件, 我只得到空值 我能够找到FormView,但不能找到Buton控件

0 个答案:

没有答案