Empty DataSetを作成し、それをGirdViewにバインドすることです。
If ds.Tables(0).Rows.Count > 0 Then
grd_codes.DataSource = ds
grd_codes.DataMember = ds.Tables(0).TableName
grd_codes.DataBind()
Else
Try
If ds.Tables(0).Rows.Count = 0 Then
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
grd_codes.DataSource = ds
grd_codes.DataBind()
Dim columnCount As Integer = grd_codes.Rows(0).Cells.Count
grd_codes.Rows(0).Cells.Clear()
grd_codes.Rows(0).Cells.Add(New TableCell)
grd_codes.Rows(0).Cells(0).ColumnSpan = columnCount
grd_codes.Rows(0).Cells(0).Text = "No Records Found."
End If
空のDataSetのバインディングにはいくつかの問題があるため、私は最初の方法を優先します。