GridView动态判断某行值后自动显示别的控件的问题
我想实现的功能是GridView里显示的某行,例如订单状态列显示:等待付款,则程序自动在傍边加上“立即支付”链接。
我的程序如下:
apsx:
<asp:TemplateField HeaderText= "订单状态 " SortExpression= "Status ">
<ItemStyle HorizontalAlign= "Center " />
<HeaderStyle HorizontalAlign= "Center " />
<ItemTemplate>
<asp:Label ID= "ddzt " runat= "server " Text= ' <%# Bind( "Status ") %> '> </asp:Label>
<asp:HyperLink ID= "zfban " runat= "server " NavigateUrl= ' <%# Eval( "CreditCard ", "UserOrdersDetail.aspx?id={0} ") %> '
Text= "立即支付 " Visible= "False "> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
cs:
HyperLink zfban = (HyperLink)GridView1.FindControl( "zfban ");
Label ddzt = (Label)GridView1.r.FindControl( "ddzt ");
if (ddzt.Text == "等待付款 ")//这行出错
{
zfban.Visible = true;
}
else
{
zfban.Visible = false;