Skip to content Skip to sidebar Skip to footer

Disabling A Button Inside A Gridview Using Jquery

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

Solution 1:

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.


Solution 2:

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

Solution 3:

Why jQuery?
Did you try LinkButton.Enabled Property?


Post a Comment for "Disabling A Button Inside A Gridview Using Jquery"