on your page load
dim strSQL as String
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("connection")
strSQL = "Your Query"
connection.Open()
Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
GridView1.DataSource = myCommand.ExecuteReader()
GridView1.DataBind()
myCommand.Dispose()
connection.close
Then follow the above codes for manipulating gridview