Reputation: 11775
I have a gridview and on the 6th column there is a link button. I want to enable/disable the link button according to the value of 7th column.... Iam using the following code. but it wont work...
$('#<%=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);
}
});
Pls Help me to correct it.. thanks in advance...
Upvotes: 1
Views: 3687
Reputation: 3156
Why you want to use Jquery to perform this task while you can achieve this easily by using Gridview's RowDataBound event. Try this one:
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
Upvotes: 1
Reputation: 187080
Try disabling the link button inside the td instead of disabling the td.
Something like
$(this).find('td:eq(6) a').attr("disabled", true);
Find the anchor tag inside the td.
But the better method will be check this in the server side itself.
You can hook the RowDataBound event and inside that you can check for this.
Upvotes: 2