i'm与vb.net中的ASP.NET(ASPX)中的GridView一起工作,其中数据是从数据加载的。包含字段:标题,类别,状态,ID和Linkaux。 昏暗的词作为新的

问题描述 投票:0回答:1

INASPX,我添加了一个名为标识符的新列,该列显示超链接。此超链接的URL取自Linkaux列,而其文本对应于ID列的值。

<asp:GridView ID="gridViewArtifacts" runat="server" CssClass="grid-margin" Style="margin-top: 4px; text-align: Justify; max-height: 200px;" Width="100%" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnRowDataBound="gridViewArtifacts_RowDataBound" OnRowCreated="gridViewArtifacts_RowCreated" OnRowCommand="gridViewArtifacts_RowCommand"> <Columns> <asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chkSelect" runat="server" OnCheckedChanged="gridViewArtifacts_CheckedChanged" AutoPostBack="true" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Identifier"> <ItemTemplate> <asp:HyperLink ID="hyperLinkID" runat="server" NavigateUrl='<%# Eval("LinkAux") %>' Text='<%# Eval("ID") %>' Target="_blank" /> </ItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="White" ForeColor="Black" /> <HeaderStyle BackColor="#005AFF" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Justify" /> <RowStyle ForeColor="Black" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F1F1F1" /> <SortedAscendingHeaderStyle BackColor="#007DBB" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#00547E" />

在接口中只想显示标识符,标题,类别和状态列,但是当前ID和Linkaux列也可见。为了隐藏他们,我正在尝试在RowDatabound事件中进行此操作,但是当加载GridView时,该事件似乎并没有发射。
Protected Sub gridViewArtifacts_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gridViewArtifacts.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim chk As CheckBox = CType(e.Row.FindControl("chkSelect"), CheckBox) If chk IsNot Nothing Then chk.Attributes.Add("onclick", "checkBoxClicked()") End If End If If e.Row.RowType = DataControlRowType.DataRow Then ' Encontre o HyperLink na linha atual Dim hyperLinkID As HyperLink = CType(e.Row.FindControl("hyperLinkID"), HyperLink) If hyperLinkID IsNot Nothing Then hyperLinkID.NavigateUrl = DataBinder.Eval(e.Row.DataItem, "LinkURL").ToString() hyperLinkID.Text = DataBinder.Eval(e.Row.DataItem, "ID").ToString() End If End If gridViewArtifacts.EnablePersistedSelection = True End Sub

是否有人经历过这种情况或有解决此问题的建议? 预先感谢您的帮助!

您确切地说,“行数据”事件的含义是什么?在您的情况下,当您进行调试器时,它不会在脱身过程中击中吗?另外,您的row_databound事件没有任何“隐藏” ID和Linxux列的代码。因此,为了隐藏这些内容,包括Row_databound事件处理程序下的以下几行,如下:

Protected Sub gridViewArtifacts_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gridViewArtifacts.RowDataBound

asp.net vb.net gridview
1个回答
0
投票

希望这有帮助!

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.