我遇到了墙,可以使用一些建议。我有一个gridview,每行包含一个“详细信息”超链接。当我处于编辑模式(内联)时,我想禁用详细信息链接。我认为这很简单,但我似乎无法使它工作。我曾经(错误地)认为我可以做类似的事情:
Dim lnkDetails As HyperLink = CType(e.Row.FindControl("lnkDetails"), HyperLink)
lnkDetails.Enabled = False
我发现这里的问题是我的Sub的“e As GridViewEditEventArgs”部分不包含“Row”。
以下是相关代码:
Protected Sub gvCurRecords_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
' Make the GridView control into edit mode for the selected row.
gvCurRecords.EditIndex = e.NewEditIndex
' Rebind the GridView control to show data in edit mode.
BindGridView()
' Hide the Add button.
lbtnAdd.Visible = False
End Sub
HTML(仅限相关专栏):
<asp:GridView ID="gvCurRecords" CellPadding="4" DataSourceId="SqlDataSource1"
Autogeneratecolumns="false" AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true" OnRowEditing="gvCurRecords_RowEditing"
OnRowCancelingEdit="gvCurRecords_RowCancelingEdit"
OnRowUpdating="gvCurRecords_RowUpdating" DataKeyNames="eventID"
OnRowDataBound="gvCurRecords_RowDataBound"
OnPageIndexChanging="gvCurRecords_PageIndexChanging" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="lnkDetails" runat="server" Text='Details' NavigateUrl='<%#FormatUrl(CInt(Eval("EventID")))%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:Gridview>
非常感谢任何帮助。感谢。
答案 0 :(得分:1)
使用编辑模板定义标签而不是超链接:
<EditItemTemplate>
<asp:Label ID="lbDetails" runat="server" Text='something else' />
</EditItemTemplate>