Friday, October 24, 2008

Generate a Random String

If you need to generate a random string of mixed characters, this simple function will do it for you:
Public Function GenerateRandomString() As String
   GenerateRandomString= System.Guid.NewGuid.ToString
End Function

This will return something like this: 80a7a705-9c23-47bc-92b6-2b5c4f9d728d. Which you then can do various string functions to make it the way you want.

Thursday, October 23, 2008

Formatting Dates in GridView

If you have a date coming back to your GridView and it displays "11/01/2008 12:00am" and you'd rather just display the date and not the time, you can fill in the DataFormatString field when editing the column, with: {0:MM/dd/yyyy}