May be you have missed just to append the new value to old value in the loop. Try this-
Dim ch As CheckBox
For i As Integer = 0 To GridView1.Rows.Count - 1
ch = CType(GridView1.Rows(i).FindControl("chk"), CheckBox)
If ch.Checked = True Then
Me.txtPrivCode.Text += "1"
ElseIf ch.Checked = False Then
Me.txtPrivCode.Text += "0"
End If
Next
Hope, it helps :)