【发布时间】:2016-09-20 19:36:41
【问题描述】:
如果 CUST_ORDER_ID = 'X' 中的值,我正在尝试隐藏“删除”链接,但我不知道如何将可见性属性设置为“False”
我的 asp.
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:BoundField DataField="ROWID" SortExpression="ROWID" Visible="False"> </asp:BoundField>
<asp:BoundField DataField="CUST_ORDER_ID" HeaderText="ORDER ID" SortExpression="CUST_ORDER_ID">
<ItemStyle Width="50px"></ItemStyle>
以及背后的代码
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'check is row non order type and allow user to delete
Dim oid As TableCell = e.Row.Cells(2)
If oid.Text = "X" Then
Dim tb As Button = e.Row.Cells(1).Controls(1)
'Dim tb = e.Row.FindControl("DeleteButton")
tb.Visible = "False"
End If
End If
End Sub
【问题讨论】:
-
您可能希望在您的 asp 问题中添加 asp/asp.net 标记以吸引 asp 的注意
-
@Plutonix 刚刚为他做了。
-
为什么不能在 HTML 中添加 Visible 属性?
-
可见属性是布尔值而不是字符串...更改此
tb.Visible = "False"totb.Visible = False -
Dim tb As Button = e.Row.Cells(1).Controls(1) 抛出此错误:指定的参数超出了有效值的范围。参数名称:索引