+2  A: 

Try:

Dim DeleteId As Guid = New Guid(Convert.ToString(e.CommandArgument))

This works...

Dim DeleteId As Guid = New Guid(DirectCast(e.CommandArgument, String))
Jonathan S.
Sorry. The problem is on line 137. I cannot cast e.CommandArgument as a Guid.
Zack Peterson
That *IS* the replacement for line 137.
James Curran
+1  A: 

The message "cast is not valid" suggests that the datatype for one of the values does not match what's in the database. Can you put a breakpoint on the line where the value of DeleteId is set and see what the Guid looks like? Then, you can compare it with what you see in the database for DogId. I suspect that you will find your datatype problem there.

DOK
Sorry. The problem is on line 137. I cannot cast e.CommandArgument as a Guid.
Zack Peterson
Aha, I'm guessing James Curran's response will solve your problem then.
DOK
+2  A: 

I'm gonna guess that e.CommandArgument is a string, which cannot by cast to a Guid. A Guid can be created from a string:

In C#:

 Guid DeleteId new Guid(e.CommandArgument);

I don't really know the VB.NET syntax, but I'll take a guess:

 Dim DeleteId As Guid = New Guid(e.CommandArgument);
James Curran
You posted this right before I finished writing mine... this is the right answer of course.
Timothy Khouri
+1  A: 

Your error has nothing to do with LINQ to SQL... it's a casting error. Use "new Guid(e.CommandArgument)".

Timothy Khouri