0

I'm working in vb.net and trying to update dgv to list a customers name instead of ID. I already have all the functions to get the customer name given the id, so that isn't much of an issue. My issue is that when I load the DataGridView, it will only select the id.

Ideally, I would like to have it pull the Name while loading, but what I've been trying is running this AFTER it's loaded

For Each row As DataGridViewRow In dgvPhones.Rows
        Dim customerID As String = ""
        Dim customerName As String

        Try
            customerID = row.Cells("Customer").Value.ToString
        Catch ex As Exception

        End Try

        customerName = CCCustomer.SelectByID(customerID).FirstNameLastName

        row.Cells("Customer").Value = customerName

    Next

I put a couple of breaks in and checked the IntelliTrace, and it's pulling in the correct values and all, but it's not actually overwriting the value in row.Cells("Customer"). It just keeps the original id number instead.

To make matters MORE confusing, I've done this before with an MEID/ESN Hex to Dec converter in the same exact place, using the exact same method, and it works just fine.

Can anybody see anything wrong with my code? I've tried using various combinations to see if it's failing because of a bad-value in the database, but it works for NULL/0/-1/1/""... so I'm kind of lost.

Chris Hobbs
  • 745
  • 2
  • 9
  • 27

1 Answers1

0

Alright, here's what I ended up doing.

Since the DataGridView was only pulling in the CustomerID, I created a new column called CustomerName and made the CustomerID hidden.

Then, I ran my code exactly as seen above, but made it so it pulled in from CustomerID, and wrote to CustomerName.

I guess CustomerID only works as an Integer... very strange, I couldn't find a property for the column saying it could only take int's, but it's working now.

Chris Hobbs
  • 745
  • 2
  • 9
  • 27