Protected Sub gvWorkingDocs_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvWorkingDocs.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
' Get the DataKey Value of the grid row
Dim newFileName As String
newFileName = gvWorkingDocs.DataKeys(e.Row.RowIndex).Value.ToString()
Dim updateButton As System.Web.UI.WebControls.Button
Dim editButton As System.Web.UI.WebControls.Button
'If a match is found then the doc is checked out
For i As Integer = 0 To dsDocsLogs.Tables(0).Rows.Count - 1
If dsDocsLogs.Tables(0).Rows(i)("NewFileName").ToString() = newFileName Then
'Fill in the status info
e.Row.Cells(8).Text = "Checked out by " + dsDocsLogs.Tables(0).Rows(i)("userName").ToString() & _
" @" + dsDocsLogs.Tables(0).Rows(i)("dateTime").ToString()
'Enable or Disable Update and Edit button
If dsDocsLogs.Tables(0).Rows(i)("userId").ToString() = userId Then
updateButton = CType(e.Row.FindControl("editWorkingDoc"), System.Web.UI.WebControls.Button)
updateButton.Enabled = True
Else 'else, disable the Edit button
editButton = CType(e.Row.FindControl("btnUpdate"), System.Web.UI.WebControls.Button)
editButton.Enabled = False
End If
End If
Next
End If
End Sub
|