Javascript 使用jquery禁用gridview中的按钮
我有一个gridview,在第6列有一个链接按钮。我想根据第7列的值启用/禁用链接按钮。。。。Iam使用以下代码。但是它不起作用Javascript 使用jquery禁用gridview中的按钮,javascript,asp.net,jquery,Javascript,Asp.net,Jquery,我有一个gridview,在第6列有一个链接按钮。我想根据第7列的值启用/禁用链接按钮。。。。Iam使用以下代码。但是它不起作用 $('#<%=xgvVisitersRegister .ClientID%> tr').each(function() { if ($(this).find('td:eq(7)').text() != "") { $(this).find('td:eq(6)').attr("disabled", true);
$('#<%=xgvVisitersRegister .ClientID%> tr').each(function() {
if ($(this).find('td:eq(7)').text() != "") {
$(this).find('td:eq(6)').attr("disabled", true);
}
else {
$(this).find('td:eq(6)').attr("disabled", false);
}
});
$('#tr')。每个(函数(){
if($(this).find('td:eq(7)').text()!=“”){
$(this.find('td:eq(6)').attr(“disabled”,true);
}
否则{
$(this).find('td:eq(6)').attr('disabled',false);
}
});
请帮我改正一下。。
提前感谢…尝试禁用td内的链接按钮,而不是禁用td 差不多
$(this).find('td:eq(6) a').attr("disabled", true);
在td内找到锚定标签
但是更好的方法是在服务器端本身检查这个
您可以挂接事件,并在其中检查是否存在此问题。为什么使用jQuery?
您尝试过吗?为什么要使用jQuery执行此任务,而您可以通过使用Gridview的RowDataBound事件轻松实现这一点。 试试这个:
Protected Sub gvSample_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSample.RowDataBound
Dim objDRV As DataRowView = CType(e.Row.DataItem, DataRowView)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim btnApprove As LinkButton = CType(e.Row.FindControl("btnApprove"), LinkButton)
If Not objDRV("Column7") Is Nothing AndAlso objDRV("Column7").ToString() <> "" Then
btnApprove.Enabled = False
Else
btnApprove.Enabled = True
End If
End If
End Sub
Protected Sub gvSample_RowDataBound(ByVal sender作为对象,ByVal e作为System.Web.UI.WebControls.GridViewRowEventArgs)处理gvSample.RowDataBound
Dim objDRV As DataRowView=CType(e.Row.DataItem,DataRowView)
如果e.Row.RowType=DataControlRowType.DataRow,则
Dim Btnaprove As LinkButton=CType(e.Row.FindControl(“Btnaprove”),LinkButton)
如果objDRV(“Column7”)不是空的,那么objDRV(“Column7”)也是空的
btnaprove.Enabled=False
其他的
btnaprove.Enabled=True
如果结束
如果结束
端接头
$(这个)。find('td:eq(6):input')
是按钮。一旦你转到jQuery,你就再也回不去了:)