在gridview中使具有特定值的链接不起作用

//前台

<asp:TemplateField HeaderText="更新">
   <HeaderStyle Font-Bold="False" Width="70px"></HeaderStyle>
      <ItemStyle HorizontalAlign="Center" />
        <ItemTemplate>
          <asp:HyperLink ID="lnkEdit" runat="server" Text="更新" Width="60" NavigateUrl='<%# "CustomerEdit.aspx?Id=" +Eval("Id")%>'>
          </asp:HyperLink>
        </ItemTemplate>
</asp:TemplateField>
 
//后台

/// <summary>
    /// 行绑定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (((System.Web.UI.WebControls.Label)e.Row.FindControl("lblID")).Text.ToString() == "")
            {
                ((HyperLink)e.Row.FindControl("lnkEdit")).Enabled = false;
            }
        }
    }

posted @ 2011-08-11 17:50  风一样的大叔  阅读(103)  评论(0编辑  收藏  举报