I have 2 grids that I bind to when selecting a vendor from the drop down and click the search button(griderror.jpg shows before I click search). Before they get their data I add a command column to each grid, works with no problems. When I click the search button they both get their data with no problems and everything looks good(GridError2.jpg shows that the data properly populated). When I click the button in the command column of the first grid it does exactly what it is suppose to. If I click the command column in the 2nd grid it errors out with the original - Object reference is not set to an instance of an object. If I do not load the first grid, but just the 2nd grid it does not error out.
This is the function that loads the grids
Any ideas on why this might be firing an error?
Thanks,
Chuck
Private
Sub
rgvDocumentsPO_CommandCellClick(sender
As
Object
, e
As
System.EventArgs)
Handles
rgvDocumentsPO.CommandCellClick
Dim
VendorID
As
Integer
= ddlDocumentsVendor.SelectedValue
Dim
documentid
As
Integer
= rgvDocumentsPO.CurrentRow.Cells(
"Document ID"
).Value
If
DataLayer.UnconfirmDocument(documentid) =
True
Then
LoadDocuments(VendorID)
Else
RadMessageBox.Show(
"You can not unconfirm this document."
)
End
If
End
Sub
Private
Sub
rgvDocumentsDrawings_CommandCellClick(sender
As
Object
, e
As
System.EventArgs)
Handles
rgvDocumentsDrawings.CommandCellClick
Dim
VendorID
As
Integer
= ddlDocumentsVendor.SelectedValue
'It errors out on this next line, but not the same line in the above Sub
Dim
documentid
As
Integer
= rgvDocumentsDrawings.CurrentRow.Cells(
"Document ID"
).Value
If
DataLayer.UnconfirmDocument(documentid) =
True
Then
LoadDocuments(VendorID)
Else
RadMessageBox.Show(
"You can not unconfirm this document."
)
End
If
End
Sub
This is the function that loads the grids
Public
Sub
LoadDocuments(
ByVal
VendorID
As
Integer
)
Try
Dim
CommandColumn
As
New
GridViewCommandColumn
CommandColumn.Name =
"Unconfirm"
CommandColumn.HeaderText =
""
CommandColumn.DefaultText =
"Unconfirm"
CommandColumn.UseDefaultText =
True
CommandColumn.TextAlignment = ContentAlignment.MiddleCenter
If
rgvDocumentsDrawings.RowCount = 0
Then
rgvDocumentsDrawings.Columns.Add(CommandColumn)
End
If
If
rgvDocumentsPO.RowCount = 0
Then
rgvDocumentsPO.Columns.Add(CommandColumn)
End
If
Catch
ex
As
Exception
End
Try
rgvDocumentsPO.DataSource = DataLayer.GetActiveDocumentsByDocTypeAndVendor(2, VendorID)
rgvDocumentsDrawings.DataSource = DataLayer.GetActiveDocumentsByDocTypeAndVendor(3, VendorID)
rgvDocumentsPO.Columns(
"Document ID"
).IsVisible =
False
rgvDocumentsDrawings.Columns(
"Document ID"
).IsVisible =
False
rgvDocumentsPO.Columns(
"Unconfirm"
).Width = 100
rgvDocumentsDrawings.Columns(
"Unconfirm"
).Width = 100
rgvDocumentsPO.BestFitColumns()
rgvDocumentsDrawings.BestFitColumns()
End
Sub
Any ideas on why this might be firing an error?
Thanks,
Chuck