//前台
<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;
}
}
}