本文介绍了在GridView无法访问HyperLinkField字段文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HyperLinkField字段定义如下:

I have a HyperLinkField defined as follows:

<asp:GridView ID="gvNotifications" runat="Server" AutoGenerateColumns="false" EnableViewState="true" CssClass="tableWhole" AlternatingRowStyle-CssClass="tableAlt">
<Columns>
    <asp:HyperLinkField HeaderText="Item#" DataTextField="sku" 
                        DataNavigateUrlFormatString="/store/item/{0}/"
                        DataNavigateUrlFields="sku" ItemStyle-CssClass="itemNo" />

在我的code-的背后,我试图访问的Text属性如下:

In my code-behind, I'm attempting to access the Text property like this:

    For Each gvRow In gvNotifications.Rows
        processItem(gvRow.Cells(0).Text.ToString)
    Next

当它被定义为一个BoundField,像这样的

这code的工作:

This code worked when it was defined as a BoundField, like this:

<asp:BoundField HeaderText="Item #" DataField="sku" ItemStyle-CssClass="itemNo" />

我如何访问一个HyperLinkField字段的Text属性在GridView.Row.Cells?

How can I access the Text property on a HyperLinkField in a GridView.Row.Cells?

推荐答案

没关系,我理解了它基于一个related C#问题。

Nevermind, I figured it out based-on a related C# question.

For Each gvRow In gvNotifications.Rows
    processItem(gvRow.Cells(0).Controls(0).Text.ToString)
Next

这篇关于在GridView无法访问HyperLinkField字段文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 23:19