Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问GridView项模板控件ASP.NET_C#_Asp.net_Gridview - Fatal编程技术网

C# 访问GridView项模板控件ASP.NET

C# 访问GridView项模板控件ASP.NET,c#,asp.net,gridview,C#,Asp.net,Gridview,我正在ASPX页面上使用ASP.NET GridView: <asp:GridView ID="GrdLimitAndUtilization" runat="server" AutoGenerateColumns="False" GridLines="None" Width="99%" meta:resourcekey="GrdAccountListResource1" OnRowDataBound="GrdLimitAndUtilization_R

我正在ASPX页面上使用ASP.NET GridView:

<asp:GridView ID="GrdLimitAndUtilization" runat="server" AutoGenerateColumns="False" GridLines="None"
                    Width="99%" meta:resourcekey="GrdAccountListResource1" OnRowDataBound="GrdLimitAndUtilization_RowDataBound"
                    ShowHeader="True" rowstyle-cssclass="rowHover" ClientIDMode="Static" CssClass="gridView">
                    <Columns>
<asp:TemplateField HeaderText="Excess" meta:resourcekey="Excess">
                            <HeaderStyle HorizontalAlign="Left" Width="120px" CssClass="gridheader" />
                            <HeaderTemplate> <asp:Label ID="col5a" Text="Excess" runat="server"></asp:Label></HeaderTemplate>
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkExcess" runat="server" value='' Text='<%# Bind("Excess") %>'
                                    meta:resourcekey="HyperLink1Resource1"></asp:HyperLink>
                                <asp:Label ID="Excess_Currency" runat="server" Text='<%# Bind("Currency") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle Width="120px" HorizontalAlign="Left" CssClass="customerProductItemTemp gridviewLeftMargin" />
                        </asp:TemplateField>
                    </Columns>
</asp:GridView>
但是,如何使用ID=“lnkExcess”?访问仅超链接控件的值/文本

谢谢。

您可以使用以下活动:-

protected void GrdLimitAndUtilization_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        HyperLink lnkExcess = (HyperLink)e.Row.FindControl("lnkExcess");
        //Access hyperlink's properties here.
     }
}

谢谢非常简单的解决方案:)
protected void GrdLimitAndUtilization_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        HyperLink lnkExcess = (HyperLink)e.Row.FindControl("lnkExcess");
        //Access hyperlink's properties here.
     }
}