如何禁用/隐藏项目模板内部的按钮?我想在加载时隐藏保存按钮,然后显示它并在单击编辑按钮时隐藏编辑按钮。在项目模板中禁用图像按钮
模板:
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButtonEdit" runat="server" CommandName="Edit" ImageUrl="loginstyling/images/Edit.png" Visible="true" />
<asp:ImageButton ID="ImageButtonUpdate" runat="server" CommandName="Update" ImageUrl="loginstyling/images/Save.png" Visible="true" OnClick="ImageButtonUpdate_Click" />
<asp:ImageButton ID="ImageButtonDelete" runat="server" CommandName="Delete" ImageUrl="loginstyling/images/Remove.png"/>
</ItemTemplate>
</asp:TemplateField>
背后:
private void ImageButtonUpdate_Click(object sender, EventArgs e)
{
ImageButtonUpdate.Enabled = false; // not working, dosnt find the button
}
你使用的是什么版本的asp.net? 也确保你清楚启用和可见 – DaniDev