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.
2008-10-31 20:20:59
Try:
Dim DeleteId As Guid = New Guid(Convert.ToString(e.CommandArgument))
This works...
Dim DeleteId As Guid = New Guid(DirectCast(e.CommandArgument, String))
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.
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);
Your error has nothing to do with LINQ to SQL... it's a casting error. Use "new Guid(e.CommandArgument)".