【发布时间】:2018-10-20 07:35:52
【问题描述】:
我有一个关于 formview 的问题,我想在 formview 上获取按钮 ID,按钮在 fvData 里面。 这是vb上的代码
Dim oButton As Button = fvData.FindControl("btnRevisi")
lblError.Visible = False
If e.CommandName = "Select" Then
fvData.ChangeMode(FormViewMode.Edit)
fvData.Caption = "Edit Data"
oButton.Visible = False
End If
HTML 上的这段代码
<asp:FormView ID="fvData" runat="server" DataSourceID="sdsForm"
DefaultMode="Edit" Width="100%" DataKeyNames="ID">
<EditItemTemplate>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2" class="FooterStyle">
<uc1:BtnUpdate ID="BtnUpdate1" runat="server" />
<uc2:BtnDelete ID="BtnDelete1" runat="server" />
<uc3:BtnCancel ID="BtnCancel1" runat="server" />
<asp:Button ID="btnRevisi" runat="server" OnClick="btnSave_Click" Style="font-size: 8pt; cursor: pointer; background-position: left; background-image: url(../images/Save.gif); background-repeat: no-repeat; text-align: right;" Text="Revisi" ToolTip="Save" ValidationGroup="Pricing" Width="55px" />
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
</table>
</EditItemTemplate>
当执行结果是 对象引用未设置为对象的实例。
如何解决这个问题?并获取 Button id
谢谢 最好的问候
【问题讨论】:
-
请包含所有代码和html标记以便我们理解。
-
好的,我已经更新了我的问题,谢谢
-
你执行的是哪个方法??
-
嗯,所以我在 gridview 上有一个命令,当 gridview = select 上的命令时,我想设置 btnRevisi Visible 为 false
-
当我想在gridview上编辑命令时执行的方法