susiana
susiana

Reputation: 43

How to disable specific rows in GridView

I want to disable specific rows of GridView in VB.NET.

I have tried, but all rows got disabled.

For a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1
    DataGridDefectProduct.Rows(a).Enabled = False
Next

error in

DataGridDefectProduct.Rows(a).Enabled = False

Please suggest if there is any alternative ways to do this.

Upvotes: 1

Views: 7724

Answers (2)

Mark
Mark

Reputation: 1

There does however appear to be a gridviewrow enabled property

Private Sub gv_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowDataBound
    If (e.Row.RowType = DataControlRowType.DataRow) Then
        If Mode = "View" Then
            e.Row().Enabled = False
        End If
    End If
End Sub

This disable the row from editing or deleting but allowed pagination to still work in view mode

Upvotes: 0

Vivek S.
Vivek S.

Reputation: 21963

  • you have to change the ReadOnly property of your Row

    For a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1
      DataGridDefectProduct.Rows(a).ReadOnly = False
    Next
    

Upvotes: 1

Related Questions